首页 > 试题广场 >

阅读下面的程序,在划线处填上正确的内容

[问答题]
阅读下面的程序,在划线处填上正确的内容,使程序完整。
建立职工情况链表,每个节点包含的成员为:姓名(name)、工资(salary)。从键盘输入节点中的所有数据,然后依次把这些节点的数据显示在屏幕上。



    struct node {
        char name[9];
        int sarlay;
        struct node *next;
    };
    struct node *head,*p;
    int i;
    head=NULL;
    for (i=0;i<3;i++) {
        p=(struct node*)malloc(sizeof(struct node));
        scanf("%s",p->name);
        scanf("%i",&p->sarlay);
        p->next=head; 
        head=p;
    }
    printf("\n");
    p=head;
    while(p) {
        printf("%s,%i\n",p->name,p->sarlay);
        p=p->next;
    }

发表于 2017-12-06 20:08:20 回复(0)
p->next = head;
p != NULL
发表于 2019-07-05 16:45:15 回复(0)