A-A+
以下程序建立了一个带有头结点的单向链表 链表结点中的数据通过键盘输入 当输人数据为-1时 表
问题详情
以下程序建立了一个带有头结点的单向链表,链表结点中的数据通过键盘输入,当输人数据为-1时,表示输入结束(链表头结点的data域不放数据,表空的条件是ph->next=NULL). include<stdio.h> struct list { int datd;struct list * next;}; 【 】creatlist() {struct list * p,*q,*ph; int a; ph= (struct list*)malloc(sizeof(struct list)); p=q=ph; printf("Input an integer number,enter-1 to end:n"); scanf("%d",&a); while(a!=-1) { p=(struct list * )malloc(sizeof(struct list)); p->data=a; q->next=p; 【 】=p; scanf("%d",&a); } p->next=; return(ph); } main() { struct list head; head=creatlist(); }
请帮忙给出正确答案和分析,谢谢!
参考答案
正确答案:struct list *q
structlist*q