19,468
社区成员
发帖
与我相关
我的任务
分享
node * create()
{
int i=0;
node *p,*q,*head;
int x=0;
head=(node*)malloc(sizeof(node));
head-> next = NULL ; //mark
while(1)
{
printf("Please input a data!\n");
scanf("%d",&x);
if(x==0) break;
p=(node*)malloc(sizeof(node));
p->data=x;
//if(++i=1)
if(head->next == NULL ) //mark
{
head->next=p;
}
else
{
q->next=p;
}
q=p;
}
q->next=NULL;
return head;
}