请问下面的c程序创建的链表有没有问题????

[复制链接]
查看11 | 回复2 | 2010-11-7 10:18:45 | 显示全部楼层 |阅读模式
ST listgreat(void)
{
int i=0;
ST *h,*p,*q;
p=(ST*)malloc(sizeof(ST));
printf("请输入第一个节点的数据:\n");
scanf("%d",p->num);
h=q;
while(i++next=p;
q=p;

p=(ST*)malloc(sizeof(ST));
if(inum);
}
}
q->next=NULL;
}

回复

使用道具 举报

千问 | 2010-11-7 10:18:45 | 显示全部楼层
我帮你改了下,你看下吧,不知道可以运行不,头节点为空。你的逻辑有点乱。typedef struct{ int num; ST *next;}ST;ST *listgreat(void){ int i=0; ST *h,*p,*q; h=(ST*)malloc(sizeof(ST)); p=h->next; while(i++num); p->next=q; p=p->next; } q->next=NULL; return
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行