运动会分数统计系统程序

上传人:206****923 文档编号:41972903 上传时间:2018-05-31 格式:DOCX 页数:11 大小:21.94KB
返回 下载 相关 举报
运动会分数统计系统程序_第1页
第1页 / 共11页
运动会分数统计系统程序_第2页
第2页 / 共11页
运动会分数统计系统程序_第3页
第3页 / 共11页
运动会分数统计系统程序_第4页
第4页 / 共11页
运动会分数统计系统程序_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《运动会分数统计系统程序》由会员分享,可在线阅读,更多相关《运动会分数统计系统程序(11页珍藏版)》请在金锄头文库上搜索。

1、#include #include #include #include /#include /*屏幕操作函数*/ #define MAX 50 /#define NULL 0 typedef struct node1 int school; /*学校编号*/ int record; /*项目成绩*/ struct node1 *next; /*链域*/ Schools; typedef struct int item; /*项目编号*/ Schools *firstschool; /*链域指向链表中第一个结点*/ ITEM; typedef struct int z; /* 项目总数 */ I

2、TEM aMAX; ALLitems; typedef struct node2 int item; /*该学校获奖的项目*/ int record; /*项目成绩*/ struct node2 *next; /*链域*/ Items; typedef struct int school; /*学校编号*/ int score; /*学校总分*/ int boys; /*男团体总分*/ int girls; /*女团体总分*/ Items *firstitem; /*链域指向链表中第一个获奖项目的结点*/ SCHNode; typedef struct int n; /* 学校总数 */ SC

3、HNode bMAX; ALLNode; ALLitems *g1; ALLNode *g2; void inputitem(ALLitems *g1,ALLNode *g2) /* 输入各个项目成绩 */ Schools *p1; Items *p2; int i,j,k,m,w,h,x; p1=(Schools *)malloc(sizeof(Schools); /添加的p2=(Items *)malloc(sizeof(Items); if(!p1|!p2)exit(1); /添加的printf(“n 重邮数理信科 2 班运动会分数统计系统“);printf(“n *输入各个项目信息 *

4、 nn“); printf(“ 输入男子项目总数 m:“); scanf(“%d“, if(m20) printf(“ 输入有误,m 是 20 以内的整数,请重新输入:“); scanf(“%d“, printf(“ 输入女子项目总数 w:“); scanf(“%d“, if(w20) printf(“ 输入有误,w 是 20 以内的整数,请重新输入:“); scanf(“%d“, printf(“ 输入参加运动会的学校总数 n:“); scanf(“%d“, if(g2-nn20) printf(“ 输入有误,n 是 20 以内的整数,请重新输入:“); scanf(“%d“, g1-z=m

5、+w;printf(“ 则项目编号为男子 1-%d,女子%d-%d“,m,m+1,g1- z); printf(“nn *记录运动会成绩*“); printf(“nn (输入 0 标志结束)n“);for(k=1;kz;k+) /* 对两个邻接表置初态 */ g1-ak.item=k; g1-ak.firstschool=NULL; for(k=1;kn;k+) g2-bk.school=k; g2-bk.firstitem=0; g2-bk.score=0;g2-bk.boys=0;g2-bk.girls=0; /g2-b0.score=0;g2-b0.boys=0;g2-b0.girls=

6、0; while(i!=0) printf(“n 项目:“); scanf(“%d“, if(i!=0) printf(“ 1.前三名 2.前五名n“); printf(“ 请选择:“); scanf(“%d“, if(j!=1 scanf(“%d“, if(j=1) /* 该项目只有前三名时执行此语句 */ h=3; do printf(“ 第%d 名:学校(学校编号为数字)“,h); scanf(“%d“, p1=(Schools *)malloc(sizeof(Schools); p1-school=x; p2=(Items *)malloc(sizeof(Items); p2-item

7、=i; if(h=3) p2-record=p1-record=2; if(h=2) p2-record=p1-record=3; if(h=1) p2-record=p1-record=5; p1-next=g1-ai.firstschool; g1-ai.firstschool=p1; p2-next=g2-bx.firstitem; g2-bx.firstitem=p2; g2-bx.score=g2-bx.score+p2-record; /* 累计总分 */ if(ibx.boys=g2-bx.boys+p2-record; /* 累计男团体总分 */ else g2-bx.girl

8、s=g2-bx.girls+p2-record; /* 累计女团体总分 */ h-; while(x!=0 if(j=2) /* 该项目有前五名时执行此语句 */ h=5; do printf(“ 第%d 名:学校(学校编号为数字)“,h); scanf(“%d“, p1=(Schools *)malloc(sizeof(Schools); p1-school=x; p2=(Items *)malloc(sizeof(Items); p2-item=i; if(h=5) p2-record=p1-record=1; if(h=4) p2-record=p1-record=2; if(h=3)

9、p2-record=p1-record=3; if(h=2) p2-record=p1-record=5; if(h=1) p2-record=p1-record=7; p1-next=g1-ai.firstschool; g1-ai.firstschool=p1; p2-next=g2-bx.firstitem; g2-bx.firstitem=p2; g2-bx.score=g2-bx.score+p2-record; /* 累计总分 */ if(ibx.boys=g2-bx.boys+p2-record; /* 累计男团体总分 */ else g2-bx.girls=g2-bx.girl

10、s+p2-record; /* 累计女团体总分 */ h-; while(x!=0 void save() /* 存储数据文件 */ FILE *fp1,*fp2; fp1=(FILE *)malloc(sizeof(FILE);fp2=(FILE *)malloc(sizeof(FILE);if(fp1=fopen(“sports1“,“wb“)=NULL) printf(“cannot open file.n“); return; if(fwrite(g1,sizeof(ALLitems),1,fp1)!=1)printf(“file write error.n“); fclose(fp1

11、); if(fp2=fopen(“sports2“,“wb“)=NULL) printf(“cannot open file.n“); return; if(fwrite(g2,sizeof(ALLNode),1,fp2)!=1) printf(“file write error.n“); fclose(fp2); void outschoolscore(ALLNode *g2) /* 输出各学校总分 */ int k; printf(“n 重邮数理信科 2 班运动会分数统计系统“); printf(“nn * 输出各学校总分 *n“); printf(“ 学校编号t 总分 n“); for(k=1;kn;k+) printf(“ %dttt %dn“,k,g2-bk.score); printf(“n“); system(“pause“);printf(“ 按任意键返回主菜单.“); getchar();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号