我第一次编一个应用程序,是运动会管理系统
要求:1,系统的操作界面,有提示用户如何操作
2,从键盘可以将学生的各项目成绩录入;
3,运动会的录入成绩可以通过对运动员姓名查询方式在屏幕上显示
4,程序具有修改资料功能
5,程序实现对文件的读取和写入操作
6,程序具有对某一项目名次进行降序排列
7,每一项目均为第一名3分,第二名2分,第三名1分,程序可以计算出所有代表队的总得分,并按降序排列.
8,程序要求可以将各个参赛队的所有队员在每个项目的成绩全部显示出来
9,程序可以用运动员的姓名来查询该队员在此次运动会上所有项目成绩
我的程序:#include<stdio.h>
#include<string.h>
#define SIZE 100
menu1()
{int a;
printf("----------");
printf("welcome to use the systerm of yundongyuan");
printf("----------\n");
printf("\t\t\t1.luru chengji\n");
printf("\t\t\t2.shuchu chengji\n");
printf("\t\t\t3.chaxun yundongyuan\n");
printf("\t\t\t4.xiugai ziliao\n");
printf("\t\t\t5.likai\n");
printf("input your choice:");
scanf("%d",&a);
while(a<0||a>5)
{printf("error!try again!\n");
printf("input your choice:");
scanf("%d",&a);}
switch(a)
{case 1:input_yund();break;
case 2:show_yund();break;
case 3:search_yund();break;
case 4:change_yund();break;
case 5:menu2();
}
}
menu2()
{printf("\n\n\n\n\n\n");
printf("-------------");
printf("welcome to use");
printf("-------------");
}
struct yundongyuan
{char name[100];
char team;
char xiangmu;
int mingci;
float chengji;
}yund[SIZE];
void save()
{FILE *fp;
int i;
if((fp=fopen("yund_list","wb"))==NULL)
{printf("cannot open file\n");
return;
}
for(i=0;i<SIZE;i++)
{if(fwrite(&yund[i],sizeof(struct yundongyuan),1,fp)!=1)
printf("file write error\n"); }
fclose(fp);
}
void load()
{FILE *fp;
int i;
if((fp=fopen("yund_dat","rb"))==NULL)
{printf("cannot open file\n");
return;}
for(i=0;i<SIZE;i++)
if(fread(&yund[i],sizeof(struct yundongyuan),1,fp)!=1)
{if(feof(fp)){fclose(fp);return;}
printf("file read error\n");
}
fclose(fp);
}
input_yund()
{int i;
printf("please input the information of yundongyuan");
for(i=0;i<SIZE;i++);
scanf("%10s%10s%10s%10d%10f",yund[i].name,yund[i].team,yund[i].xiangmu,&yund[i].mingci,&yund[i].chengji);
save();
}
show_yund()
{int i;
FILE *fp;
fp=fopen("yund_list","rb");
for(i=0;i<SIZE;i++)
{fread(&yund[i],sizeof(struct yundongyuan),1,fp);
printf("%10s%10s%10s%10d%10f\n",yund[i].name,yund[i].team,yund[i].xiangmu
,yund[i].mingci,yund[i].chengji);
}
fclose(fp);
}
search_yund()
{int i;
char str1[10];
FILE *fp;
fp=fopen("yund_list","wb");
printf("please input the name of yundongyuan");
gets(str1);
for(i=0;i<SIZE;i++)
{if(strcmp(str1,yund[i].name)==0)
printf("____name___team__xiangmu___mingci___chengji__\n");
printf("%10s%10s%10s%10d%10f",yund[i].name,yund[i].team,yund[i].xiangmu,yund[i].mingci,yund[i].chengji);
break;}
fclose(fp);
}
change_yund()
{int i,b,c;
char str[10];
printf("input the yundongyuan`s name you want to change:");
gets(str);
for(i=0;i<100;i++)
{if(strcmp(str,yund[i].name)==0)
printf("____name___team__xiangmu___mingci___chengji__\n");
printf("%10s%10s%10s%10d%10f",yund[i].name,yund[i].team,yund[i].xiangmu,yund[i].mingci,
yund[i].chengji); c=i;
break;}
printf("choose which you want to change:\n");
printf("1.name 2.team 3.xiangmu 4.mingci 5.chengji 6.back");
scanf("%d",&b);
switch(b)
{case 1:printf("input new name:");scanf("%s",yund[c].name);break;
case 2:printf("input new team:");scanf("%s",yund[c].team);break;
case 3:printf("input new xiangmu:");scanf("%s",yund[c].xiangmu);break;
case 4:printf("input new mingci:");scanf("%d",&yund[c].mingci);break;
case 5:printf("input new chengji:");scanf("%f",&yund[c].chengji);break;
case 6:menu1();break;
}
}
void main()
{load();
menu1();
save();
}这是我这几天写的,在TC上也能运行了,可是(6),(7)还没写出来,排序我也知道用冒泡或选择,可关键是不知道怎么对数据进行处理,就是让程序把符合项输出进行排序,请大家帮忙啊