#include
#include #include #include #define n 1//参赛学校个数(可根据情况更改 ) #define m 1//男子项目数 #define w 1//女子项目数 typedef struct { int top; //取名次数目 int range[5];//排名 int mark[5]; //积分 int itemnum;//项目编号 }itemnode;//定义项目结点 typedef struct { int schoolnum;// 学校编号 int score;// 学校总分 int mscore;// 男子团体总分 int wscore;// 女子团体总分 itemnode c[m+w];//项目数组 }headnode;//定义头结点 headnode h[n];//定义头结点数组 void inputinformation();//录入信息函数 void outputinformation();//显示信息函数 void chaxun();// 查询函数 void writefile(); //写文件 void readfile();//读取文件 /////////////录入信息///////////// void inputinformation() { int i,j,k,s; for(i=0;in) printf("错误:这个学校没有参加此次运动会!\n"); else { printf("要查询的项目编号:"); scanf("%d",&j); if(j>m+w||j==0) printf("此次运动会没有这个项目\n"); else { printf("这个项目取前 %d名,该学校的成绩如下:\n", h[0].c[j-1].top); for(k=0;k<5;k++) if(h[i-1].c[j-1].range[k]!=0) printf("名次:%d\n",h[i-1].c[j-1].range[k]); } } printf("是否继续操作(1/0)?:"); scanf("%d",&s); printf("\n"); }while(s==1); //循环执行输出语句 break; case 2: do { printf("要查询的项目编号:"); scanf("%d",&s); if(s>m+w||s==0) printf("此次运动会不包括这个项目\n"); else { printf("该项目取前 %d名,取得名次的学校\n",h[0].c[s-1].top); for(i=0; i内容 //////////////////////////////主函数///////////////// int main() { FILE *fp; int choice; int flag1=1,flag2=1; system("cls"); do { system("color 2f"); sleep(200); printf("\n***********************\1\1欢迎使用程序\1\1************************\n"); sleep(200); printf("\n******************\1\1校级运动会分数统计系统\1\1*******************\n"); printf("\n\n ***1.录入信息******\n"); sleep(200); printf("\n\n ***2.显示信息******\n"); sleep(200); printf("\n\n ***3.查询信息******\n"); sleep(200); printf("\n\n ***4.退出程序******\n"); sleep(200); printf("\n*******************************\2\2******************************\n"); printf("\n\n请根据提示选择操作!:"); scanf("%d",&choice); if(choice==1)flag1=0; else if((fp=fopen("sportsdata.txt","r"))!=NULL )flag2=0; else { system("cls"); printf("没有信息,请你录入信息!\n"); } }while(flag1&&flag2); switch(choice) { case 1: printf("\n==========请输入信息========\n");inputinformation(); writefile();printf("==========信息已存入档=========");main(); case 2: printf("===========输出信息==========\n"); if(flag1)readfile(); outputinformation();main(); case 3: printf("===========查询信息==========\n"); if(flag1)readfile(); chaxun();main(); case 4: printf("\n\2\2退出系统!谢谢使用!\2\2\n\n"); exit(0); default: printf("输入错误!\n"); exit(0); } }