c语言程序设计实验报告答案_c语言程序设计实验报告


【资料图】

1、代码:# include # includechar stu_no[10][10]; int c_math[10],c_en[10],c_computer[10],point[10],average[10]; int i,j,max; char c; void input() { for(i=0;i<=9;i++) /*输入学生成绩*/ { printf("请输入学号:"); scanf("%s",&stu_no[i]); printf("请输入数学成绩:"); scanf("%d",&c_math[i]); printf("请输入英语成绩:"); scanf("%d",&c_en[i]); printf("请输入计算机基础成绩:"); scanf("%d",&c_computer[i]); } for(i=0;i<=10;i++) /*计算总分跟平均分*/ { point[i]=c_math[i]+c_en[i]+c_computer[i]; average[i]=point[i]/3; } } void paixu() { printf("成绩按从高到低排列为:"); printf("学号 数学 英语 计算机基础 总分 平均分"); for (i=0;i<=10;i++) { for(j=1;j<=10;j++) if (point[i]>point[j]) max=i; printf("%s,d,%d,%d,%d,%d,%d",stu_no[max],c_math[max],c_en[max],c_computer[max],point[max],average[max]); } } void main() { input(); paixu();}用链表:#include #include #ifndef NULL#define NULL 0#endif#define LEN sizeof(struct student)struct student{ long num; float score; struct student *next;};int n;struct student *creat(void){ struct student *head; struct student *p1,*p2; n=0; p1=p2=(struct student *)malloc(LEN); scanf("%ld,%f",&p1->num,&p1->score); head=NULL; while(p1->num!=0) { n=n+1; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=(struct student *)malloc(LEN); scanf("%ld,%f",&p1->num,&p1->score); } p2->next=NULL; return(head);}void print(struct student *head){ struct student *p; printf("Now,These %d records are:",n); p=head; if(head!=NULL) do { printf("%ld %5.1f",p->num,p->score); p=p->next; }while(p!=NULL);}struct student *del(struct student *head,long num){ struct student *p1, *p2; if(head==NULL){printf("list null!");return NULL;} p1=head; while(num!=p1->num && p1->next!=NULL) {p2=p1;p1=p1->next;} if(num==p1->num) { if(p1==head) head=p1->next; else p2->next=p1->next; printf("delete:%ld",num); n=n-1; } else printf("%ld not been found!",num); return(head);}struct student *insert(struct student *head, struct student *stud){ struct student *p0,*p1,*p2; p1=head; p0=stud; if(head==NULL) {head=p0;p0->next=NULL;} else { while((p0->num > p1->num) && (p1->next != NULL)) { p2=p1; p1=p1->next; } if (p0->num <= p1->num) { if(head==p1) head=p0; else p2->next=p0; p0->next=p1; } else {p1->next=p0;p0->next=NULL;} } n=n+1; return head;}void main(){ struct student *head, *stu; long del_num; printf("input records:"); head=creat(); print(head); printf("input the deleted number:"); scanf("%ld",&del_num); while(del_num!=0) { head=del(head,del_num); print(head); printf("input the deleted record:"); scanf("%ld",&del_num); } printf("input the inserted record:"); stu=(struct student *)malloc(LEN); scanf("%ld,%f",&stu->num,&stu->score); while(stu->num!=0) { head=insert(head,stu); print(head); printf("input the inserted record:"); stu=(struct student *)malloc(LEN); scanf("%ld,%f",&stu->num,&stu->score); }}挺好的。

本文到此分享完毕,希望对大家有所帮助。

标签:

最近更新

c语言程序设计实验报告答案_c语言程序设计实验报告
2023-06-15 14:09:42
为先进制造业“充电”:让世界爱上中国智造
2023-06-15 14:02:55
世界新消息丨射洪二手房最近急售电梯房(射洪二手房)
2023-06-15 13:16:13
天天快资讯丨夏日的一抹金黄!彭浦四季公园金丝桃盛开
2023-06-15 13:17:59
世界今热点:中亚杯:乌兹伊朗率先出线,国足苦手逼平弱旅后排名垫底
2023-06-15 12:28:14
生物竞赛强省有哪些一等奖什么好处
2023-06-15 12:12:47
央行今日开展2370亿元MLF操作 利率下调10个基点
2023-06-15 11:55:24
看热讯:2023年常州10所民办小升初摇号录取名单查询入口
2023-06-15 12:03:59
重庆:“一库一站一平台”促进高校毕业生就业
2023-06-15 11:49:33
环球头条:深水海纳:6月14日融资买入431.19万元,融资融券余额5087.6万元
2023-06-15 11:35:04
世界新资讯:承诺失效的情况指的是哪些呢,有哪些规定
2023-06-15 11:04:19
天天速讯:北京:16项辅助生殖项目7月起纳入基本医保
2023-06-15 10:56:45
环球观察:一图读懂:港股较美股“便宜程度”再次触及历史较高水平
2023-06-15 10:42:34
等待梅西-当前快看
2023-06-15 10:59:46
纳雍县张家湾镇450亩莲花白长势喜人|消息
2023-06-15 10:24:06
【全球播资讯】大学生带瘫痪父亲上学:已带6年 考研也要带上他
2023-06-15 10:20:14
美国继英国后也拟向乌克兰提供贫铀弹
2023-06-15 09:45:12
环球快资讯:鲟怎么读_蕈怎么读
2023-06-15 10:01:17
铂金价格走势图 今日最新铂金行情(2023年6月15日)
2023-06-15 09:26:44
提前准备不慌张!新西兰留学签证材料清单来啦
2023-06-15 09:09:42
“别以为我是科学家就不敢打击犯罪”,墨西哥女市长辞职参选总统
2023-06-15 09:06:13
山东省沂水县市场监管局:持续开展“打传销、反欺诈、促和谐”全民动员集中宣传活动_环球今亮点
2023-06-15 09:00:47
ChatGPT迎重磅更新,降价25-75%!解析ChatGPT技术原理_环球视点
2023-06-15 08:08:35
光鸟云盘怎么样(光鸟云盘)|天天快看
2023-06-15 08:00:07
“火”力全开稳供电 热消息
2023-06-15 07:38:26
湖南大学-广西电网公司签署全面深化合作协议
2023-06-15 07:29:32
简讯:【代表委员建言】增强职业教育认可度吸引力
2023-06-15 06:52:44
歌手张恒远英年早逝,刚和歌手毕夏结婚不久,毕夏生前心愿惹人泪_每日精选
2023-06-15 06:23:05
“助浴”服务更显扶残温度 当前关注
2023-06-15 05:51:11
工业气体板块6月14日跌0.04%,福斯达领跌,主力资金净流出1.65亿元
2023-06-15 05:20:26