2022年数据结构课设-运动会分数统计源码 .pdf





《2022年数据结构课设-运动会分数统计源码 .pdf》由会员分享,可在线阅读,更多相关《2022年数据结构课设-运动会分数统计源码 .pdf(12页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、#include #include #include typedef struct School / 学校 int num; / 学校编号int sumscore; / 学校总成绩int score; / 获奖项目成绩int man; / 男团总成绩int woman; / 女团总成绩int n; / 学校总数char name15; / 学校名称School11; typedef struct Item int Inum6; / 获奖项目编号int Iscore2121; / 项目成绩int Isum; / 项目总数Item11; Item11 Item121; School11 Schoo
2、l121; void Putscore() / 输入成绩函数 int m,w,k,b,j,h; printf(n); printf(n *请输入各项目信息*nn); printf( 输入学校总数:); scanf(%d,&School10.n); while(School10.n20) printf( 输入错误,请重新输入。n); printf( 输入学校总数:); scanf(%d,&School10.n); printf( 输入男子项目总数:); scanf(%d,&m); while(m=20) printf( 输入错误,请重新输入。n); printf( 输入男子项目总数:); 名师资
3、料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 12 页 - - - - - - - - - scanf(%d,&m); printf( 输入女子项目总数:); scanf(%d,&w); while(w20) printf( 输入错误,请重新输入。n); printf( 输入女子项目总数:); scanf(%d,&w); Item10.Isum=m+w; printf( 男子项目编号为1 至%dn,m); printf( 女子项目编号为%d至%dn,m+1,m+w); for
4、(k=1;k=School10.n;k+) printf( 输入第 %d 个学校名称: ,k); scanf(%s,&School1k.name); School1k.sumscore=0; School1k.man=0; School1k.woman=0; School1k.num=k; printf( 输入项目编号,以-1 作为结束: ); scanf(%d,&b); while(b!=EOF) / 以-1 为结束 printf( 前三名按3,前五名按5:); scanf(%d,&j); while(j!=3&j!=5) printf( 输入错误,请重新输入。n); printf( 前三名
5、按3,前五名按5:); scanf(%d,&j); if(j=3) printf( 输入获得第一名的学校编号:); scanf(%d,&h); Item10.Iscorehb=5; Item1b.Inum1=h; School1h.score=School1h.score+5; if(b=m) School1h.man=School1h.man+5; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 12 页 - - - - - - - - - else School1h.
6、woman=School1h.woman+5; printf( 输入获得第二名的学校编号:); scanf(%d,&h); Item10.Iscorehb=3; Item1b.Inum2=h; School1h.score=School1h.score+3; if(b=m) School1h.man=School1h.man+3; else School1h.woman=School1h.woman+3; printf( 输入获得第三名的学校编号:); scanf(%d,&h); Item10.Iscorehb=2; Item1b.Inum3=h; School1h.score=School1
7、h.score+2; if(b=m) School1h.man=School1h.man+2; else School1h.woman=School1h.woman+2; if(j=5) printf( 输入获得第一名的学校编号:); scanf(%d,&h); Item10.Iscorehb=7; Item1b.Inum1=h; School1h.score=School1h.score+7; if(b=m) School1h.man=School1h.man+7; else School1h.woman=School1h.woman+7; printf( 输入获得第二名的学校编号:); s
8、canf(%d,&h); Item10.Iscorehb=5; Item1b.Inum2=h; School1h.score=School1h.score+5; if(b=m) School1h.man=School1h.man+5; else School1h.woman=School1h.woman+5; printf( 输入获得第三名的学校编号:); scanf(%d,&h); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 12 页 - - - - - - - -
9、 - Item10.Iscorehb=3; Item1b.Inum3=h; School1h.score=School1h.score+3; if(b=m) School1h.man=School1h.man+3; else School1h.woman=School1h.woman+3; printf( 输入获得第四名的学校编号:); scanf(%d,&h); Item10.Iscorehb=2; Item1b.Inum4=h; School1h.score=School1h.score+2; if(b=m) School1h.man=School1h.man+2; else School
10、1h.woman=School1h.woman+2; printf( 输入获得第五名的学校编号:); scanf(%d,&h); Item10.Iscorehb=1; Item1b.Inum5=h; School1h.score=School1h.score+1; if(b=m) School1h.man=School1h.man+1; else School1h.woman=School1h.woman+1; printf( 输入项目编号,以-1 作为结束: ); scanf(%d,&b); system(pause); printf( 按任意键返回 ); getchar(); system
11、(cls); void save() / 存储数据文件 FILE *fp1,*fp2; int i,j; if(fp1=fopen(a1,wb)=NULL) / 打开文件 printf(cannot open this filen); return; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 12 页 - - - - - - - - - for(i=0;i20;i+) if(fwrite(&Item1i,sizeof(struct Item),1,fp1)!=1)
12、/ 写数据块printf(file write errorn); fclose(fp1); / 关闭文件if(fp2=fopen(a2,wb)=NULL) / 打开文件 printf(cannot open this filen); return; for(j=0;j20;j+) if(fwrite(&School1j,sizeof(struct School),1,fp2)!=1) / 写数据块printf(file write errorn); fclose(fp2); / 关闭文件 void totalscore(School11 r) / 统计各学校总分 int k; printf(n
13、n * 输出各学校总分*n); printf( 学校编号学校总分n); for(k=1;k=r0.n;k+) School1k.sumscore=School1k.man+School1k.woman; printf( %d %d,School1k.num,School1k.sumscore); printf(n); system(pause); printf( 按任意键返回 ); getchar(); system(cls); void schoolname(School11 School120) / 按名称排序 int i,j; School11 t; for(i=1;iSchool10.
14、n;i+) for(j=i+1;j0) t=School1i; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 12 页 - - - - - - - - - School1i=School1j; School1j=t; printf(n *按名称排列 :*n); printf( 学校编号学校名称总分男子总分女子总分n); for(i=1;i=School10.n;i+) printf( %2d%8s%7d%8d%8dn, School1i.num,School1i.nam
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年数据结构课设-运动会分数统计源码 2022 数据结构 运动会 分数 统计 源码

限制150内