| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 536 人关注过本帖
标题:请教,多谢指点
取消只看楼主 加入收藏
nainiu
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2004-6-6
收藏
 问题点数:0 回复次数:0 
请教,多谢指点

做了一个作业,但是编译的时候老是提示错误 "typedef struct student link;"中有太多的类型.请问这是怎么回事啊?

#define NULL 0 struct student { char num; char name; float Chinese; float English; float Math; struct student *next; } typedef struct student link; link *p; link *p1,*p2,*head ; void creat() { int n=0; head=NULL; p1=p2=(struct student *)malloc(sizeof(struct student)); printf("please input the number,name,Chinese score,English score,Math score."); scanf("%c,%c,%f,%f,%f,",&p1->num,&p1->name,&p1->Chinese,&p1->English,&p1->Math); if(p1->num!=0) n=n+1; head=p1; do { p1=(struct student *)malloc(sizeof(struct student)); printf("please input the number,name,Chinese score,English score,Math score."); scanf("%c,%c,%f,%f,%f,",&p1->num,&p1->name,&p1->Chinese,&p1->English,&p1->Math); p2->next=p1; p2=p1; n+=1; } while(p1->num!=0); p1->next=NULL; } void Outstudent() { p=head; do { printf("%c,%c,%f,%f,%f,",p1->num,p1->name,p1->Chinese,p1->English,p1->Math); p=p->next; } while(p->next!=NULL); } void Insert() { p1=(struct student *)malloc(sizeof(struct student)); printf("please input the number,name,Chinese score,English score,Math score."); scanf("%c,%c,%f,%f,%f,",&p1->num,&p1->name,&p1->Chinese,&p1->English,&p1->Math); p2->next=p1; p2=p1; p1->next=NULL;

} void Delete() { char m; struct student *p1,*p2; printf("please input the number of the student you want to delete."); scanf("%c",&m); p=head; if(p->num=m) head=p->next; else do { p1=p; p=p->next; p2=p->next; }while(p->num!=m); p1->next=p2; free(p); }

main() { int i; creat(); printf("please select an ability:1 for Outstudent,2 for Insert,3 for Delete;"); scanf("%d",&i); if(i=1) Outstudent(); else if(i=2) Insert(); else Delete(); }

2004-11-14 16:48
快速回复:请教,多谢指点
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011600 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved