第1个回答 2011-12-13
struct NODE
{ int data;
struct NODE *next;
};
typedef struct NODE SLIST;
SLIST *creat_list()
{ SLIST *h,*s,*r;
int c;
h=(SLIST *)malloc(sizeof(SLIST));//创建头节点
r=h;
scanf("%d",&c);
while(c!=-1)
{ s=(SLIST *)malloc(sizeof(SLIST));//建立新节点
s->data=c;
r->next=s;
r=s;
scanf("%d",&c);
}
r->next='\0';
return h;
}
main()
{ SLIST *head;
head=creat_list();
}