|
|
|
@ -39,6 +39,9 @@ struct xmform1{
|
|
|
|
|
char mc4[10];
|
|
|
|
|
char mc5[10];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct xmform2{
|
|
|
|
|
char name[20];
|
|
|
|
|
char mc1[10];
|
|
|
|
@ -46,6 +49,7 @@ struct xmform2{
|
|
|
|
|
char mc3[10];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct schoolform{
|
|
|
|
|
char name[20];
|
|
|
|
|
char id[10];
|
|
|
|
@ -53,6 +57,7 @@ struct schoolform{
|
|
|
|
|
int scoer=0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct studentform{
|
|
|
|
|
char name[20];
|
|
|
|
|
char xb[10];
|
|
|
|
@ -66,6 +71,8 @@ struct studentform{
|
|
|
|
|
} xm;
|
|
|
|
|
int allscoer;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ggy(struct studentform student[]){
|
|
|
|
|
printf("请输入参加比赛的选手个数\n");
|
|
|
|
|
int n;
|
|
|
|
@ -112,6 +119,7 @@ struct studentform{
|
|
|
|
|
fprintf(fp,"%10s%5s%10s%5d%10s%10s",student[i].name,student[i].xb,student[i].number,student[i].age,student[i].name1,student[i].xm.name);
|
|
|
|
|
}
|
|
|
|
|
printf("存储完成\n");
|
|
|
|
|
fclose(fp);
|
|
|
|
|
printf("开始创造打开密匙\n");
|
|
|
|
|
if((fp=fopen("studentrs","wb+"))==NULL){
|
|
|
|
|
printf("打开密匙创造未成功\n");
|
|
|
|
@ -121,9 +129,12 @@ struct studentform{
|
|
|
|
|
}
|
|
|
|
|
fprintf(fp,"%5d",n);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
printf("********************\n");}
|
|
|
|
|
return n;
|
|
|
|
|
}}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ggy1(struct schoolform school[]){
|
|
|
|
|
printf("请输入参加比赛的学校个数\n");
|
|
|
|
|
int n;
|
|
|
|
@ -180,6 +191,8 @@ struct studentform{
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ggy2(struct xmform1 xm1[],struct studentform student[],struct schoolform school[],int schoolgs,int studentrs){
|
|
|
|
|
printf("请输入这一类项目的个数:\n");
|
|
|
|
|
int n;
|
|
|
|
@ -190,7 +203,7 @@ struct studentform{
|
|
|
|
|
for(i=0;i<n;i++){
|
|
|
|
|
printf("请输入该类第%d个项目名称:\n",i+1);
|
|
|
|
|
gets(xm1[i].name);
|
|
|
|
|
printf("输入该个项目获奖情况:第一名 第二名 第三名 第四名 第五名(依次按顺序输入姓名,注:输一个名字按一次回城)");
|
|
|
|
|
printf("输入该个项目获奖情况:第一名 第二名 第三名 第四名 第五名(依次按顺序输入姓名,注:输一个名字按一次回城)\n");
|
|
|
|
|
gets(xm1[i].mc1);
|
|
|
|
|
for(i1=0;i1<studentrs;i1++){
|
|
|
|
|
|
|
|
|
@ -288,6 +301,8 @@ struct studentform{
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ggy3(struct xmform2 xm2[],struct studentform student[],struct schoolform school[],int schoolgs,int studentrs){
|
|
|
|
|
printf("请输入这一类项目的个数:\n");
|
|
|
|
|
int n;
|
|
|
|
@ -298,7 +313,7 @@ struct studentform{
|
|
|
|
|
for(i=0;i<n;i++){
|
|
|
|
|
printf("请输入该类第%d个项目名称:\n",i+1);
|
|
|
|
|
gets(xm2[i].name);
|
|
|
|
|
printf("输入该个项目获奖情况:第一名 第二名 第三名 (依次按顺序输入姓名,注:输一个名字按一次回车)");
|
|
|
|
|
printf("输入该个项目获奖情况:第一名 第二名 第三名 (依次按顺序输入姓名,注:输一个名字按一次回车)\n");
|
|
|
|
|
gets(xm2[i].mc1);
|
|
|
|
|
for(i1=0;i1<studentrs;i1++){
|
|
|
|
|
|
|
|
|
@ -359,6 +374,9 @@ struct studentform{
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void xscz(struct studentform student[],int studentrs){ //定义一个选手查找并输出函数 (按姓名查找)
|
|
|
|
|
printf("请输入你要查找的选手名字\n");
|
|
|
|
|
char name[20];
|
|
|
|
@ -367,7 +385,7 @@ struct studentform{
|
|
|
|
|
for(i=0;i<studentrs;i++){
|
|
|
|
|
a=strcmp(student[i].name,name);
|
|
|
|
|
if(a==0){
|
|
|
|
|
printf("将依次输出该选手信息:\n");
|
|
|
|
|
printf("将依次输出该选手信息:\n\a");
|
|
|
|
|
printf("姓名:%s 性别:%s 年龄:%d 编号:%s \n",student[i].name,student[i].xb,student[i].age,student[i].number);
|
|
|
|
|
printf("所属学校:%s 参加项目名称:%s 名次:%s 总分数:%d \n",student[i].name1,student[i].xm.name,student[i].xm.mc,student[i].xm.scoer);
|
|
|
|
|
a1=1; //防止有些选手信息未记录而找不到
|
|
|
|
@ -381,6 +399,9 @@ struct studentform{
|
|
|
|
|
}
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void xscz1(struct studentform student[],int studentrs){ //定义一个选手查找并输出函数 (按编号查找)
|
|
|
|
|
printf("请输入你要查找的选手编号\n");
|
|
|
|
|
char number[20];
|
|
|
|
@ -389,7 +410,7 @@ struct studentform{
|
|
|
|
|
for(i=0;i<studentrs;i++){
|
|
|
|
|
a=strcmp(student[i].number,number);
|
|
|
|
|
if(a==0){
|
|
|
|
|
printf("将依次输出该选手信息:\n");
|
|
|
|
|
printf("将依次输出该选手信息:\n\a");
|
|
|
|
|
printf("姓名:%s 性别:%s 年龄:%d 编号:%s \n",student[i].name,student[i].xb,student[i].age,student[i].number);
|
|
|
|
|
printf("所属学校:%s 参加项目名称:%s 名次:%s 总分数:%d ",student[i].name1,student[i].xm.name,student[i].xm.mc,student[i].xm.scoer);
|
|
|
|
|
a1=1; //防止有些选手信息未记录而找不到
|
|
|
|
@ -403,6 +424,9 @@ struct studentform{
|
|
|
|
|
}
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void xmcz1(struct xmform1 xm1[],int xmgs1){
|
|
|
|
|
printf("请输入你要查找的项目名称\n");
|
|
|
|
|
char name[20];
|
|
|
|
@ -411,7 +435,7 @@ struct studentform{
|
|
|
|
|
for(i=0;i<xmgs1;i++){
|
|
|
|
|
a=strcmp(xm1[i].name,name);
|
|
|
|
|
if(a==0){
|
|
|
|
|
printf("将依次输出该项目信息:\n");
|
|
|
|
|
printf("将依次输出该项目信息:\n\a");
|
|
|
|
|
printf("项目名称是:%s\n",xm1[i].name);
|
|
|
|
|
printf("第一名:%s 第二名:%s 第三名:%s 第四名:%s 第五名:%s ",xm1[i].mc1,xm1[i].mc2,xm1[i].mc3,xm1[i].mc4,xm1[i].mc5);
|
|
|
|
|
a1=1; //防止有些选手信息未记录而找不到
|
|
|
|
@ -425,6 +449,9 @@ struct studentform{
|
|
|
|
|
}
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void xmcz2(struct xmform2 xm2[],int xmgs2){
|
|
|
|
|
printf("请输入你要查找的项目名称\n");
|
|
|
|
|
char name[20];
|
|
|
|
@ -433,7 +460,7 @@ struct studentform{
|
|
|
|
|
for(i=0;i<xmgs2;i++){
|
|
|
|
|
a=strcmp(xm2[i].name,name);
|
|
|
|
|
if(a==0){
|
|
|
|
|
printf("将依次输出该项目信息:\n");
|
|
|
|
|
printf("将依次输出该项目信息:\n\a");
|
|
|
|
|
printf("项目名称是:%s\n",xm2[i].name);
|
|
|
|
|
printf("第一名:%s 第二名:%s 第三名:%s \n",xm2[i].mc1,xm2[i].mc2,xm2[i].mc3);
|
|
|
|
|
a1=1; //防止有些选手信息未记录而找不到
|
|
|
|
@ -447,6 +474,9 @@ struct studentform{
|
|
|
|
|
}
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void xxcz1(struct schoolform school[],int schoolgs){
|
|
|
|
|
printf("请输入你要查找的学校名称\n");
|
|
|
|
|
char name[20];
|
|
|
|
@ -455,7 +485,7 @@ struct studentform{
|
|
|
|
|
for(i=0;i<schoolgs;i++){
|
|
|
|
|
a=strcmp(school[i].name,name);
|
|
|
|
|
if(a==0){
|
|
|
|
|
printf("将依次输出该学校信息:\n");
|
|
|
|
|
printf("将依次输出该学校信息:\n\a");
|
|
|
|
|
printf("名称:%s 编号:%s 参赛人数:%d 总分数:%d \n",school[i].name,school[i].id,school[i].number,school[i].scoer);
|
|
|
|
|
//printf("所属学校:%s 参加项目名称:%s 名次:%s 总分数:%d ",student[i].name1,student[i].xm.name,student[i].xm.mc,student.xm.score);
|
|
|
|
|
a1=1; //防止有些选手信息未记录而找不到
|
|
|
|
@ -469,15 +499,18 @@ struct studentform{
|
|
|
|
|
}
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void xxcz2(struct schoolform school[],int schoolgs){
|
|
|
|
|
printf("请输入你要查找的学校编号\n");
|
|
|
|
|
printf("请输入你要查找的学校编号\n\a");
|
|
|
|
|
char number[20];
|
|
|
|
|
gets(number);
|
|
|
|
|
int i,a,a1=0;
|
|
|
|
|
for(i=0;i<schoolgs;i++){
|
|
|
|
|
a=strcmp(school[i].id,number);
|
|
|
|
|
if(a==0){
|
|
|
|
|
printf("将依次输出该选学校信息:\n");
|
|
|
|
|
printf("将依次输出该选学校信息:\n\a");
|
|
|
|
|
printf("名称:%s 编号:%s 参赛人数:%d 总分数:%d \n",school[i].name,school[i].id,school[i].number,school[i].scoer);
|
|
|
|
|
//printf("所属学校:%s 参加项目名称:%s 名次:%s 总分数:%d ",student[i].name1,student[i].xm.name,student[i].xm.mc,student.xm.score);
|
|
|
|
|
a1=1; //防止有些选手信息未记录而找不到
|
|
|
|
@ -491,6 +524,9 @@ struct studentform{
|
|
|
|
|
}
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void schoolph(struct schoolform school[],int schoolgs){
|
|
|
|
|
int max=school[0].scoer; int maxnumber=0;
|
|
|
|
|
int ph[50];
|
|
|
|
@ -507,8 +543,9 @@ struct studentform{
|
|
|
|
|
school[maxnumber].scoer=t;
|
|
|
|
|
schoolgs-=1;
|
|
|
|
|
ph[i1]=maxnumber;
|
|
|
|
|
max=school[0].scoer; maxnumber=0;
|
|
|
|
|
}
|
|
|
|
|
printf("学校排行由高到低输出依次是:\n");
|
|
|
|
|
printf("学校排行由高到低输出依次是:\n\a");
|
|
|
|
|
schoolgs=t1;
|
|
|
|
|
//printf("学校个数是%d\n",schoolgs);
|
|
|
|
|
for(i=0;i<schoolgs;i++){
|
|
|
|
@ -516,6 +553,8 @@ struct studentform{
|
|
|
|
|
}
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void studentph(struct studentform student[],int studentrs){
|
|
|
|
|
int max=student[0].xm.scoer;int maxnumber=0;
|
|
|
|
|
int ph[50];
|
|
|
|
@ -532,15 +571,19 @@ struct studentform{
|
|
|
|
|
student[maxnumber].xm.scoer=t;
|
|
|
|
|
studentrs-=1;
|
|
|
|
|
ph[i1]=maxnumber;
|
|
|
|
|
max=student[0].xm.scoer; maxnumber=0;
|
|
|
|
|
}
|
|
|
|
|
printf("学生排行由高到低输出依次是:\n");
|
|
|
|
|
printf("学生排行由高到低输出依次是:\n\a");
|
|
|
|
|
studentrs=t1;
|
|
|
|
|
for(i=0;i<studentrs;i++){
|
|
|
|
|
printf("姓名:%s 分数:%d\n",student[ph[i]].name,student[ph[i]].xm.scoer);
|
|
|
|
|
}
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
}
|
|
|
|
|
void dudan1(struct schoolform school[]){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void dudan1(struct schoolform school[],int *schoolgs1){
|
|
|
|
|
int schoolgs;
|
|
|
|
|
printf("开始打开密匙\n");
|
|
|
|
|
if((fp=fopen("schoolgs","rb+"))==NULL){
|
|
|
|
@ -551,6 +594,7 @@ struct studentform{
|
|
|
|
|
}
|
|
|
|
|
rewind(fp);
|
|
|
|
|
fscanf(fp,"%5d",&schoolgs);
|
|
|
|
|
*schoolgs1=schoolgs;
|
|
|
|
|
fclose(fp);
|
|
|
|
|
int i;
|
|
|
|
|
printf("开始打开文件\n");
|
|
|
|
@ -560,6 +604,7 @@ struct studentform{
|
|
|
|
|
}else{
|
|
|
|
|
printf("文件已经安全打开了\n");
|
|
|
|
|
}
|
|
|
|
|
//printf("%d",schoolgs);
|
|
|
|
|
rewind(fp); //将文件指针移到最前面
|
|
|
|
|
for(i=0;i<schoolgs;i++){
|
|
|
|
|
|
|
|
|
@ -568,7 +613,10 @@ struct studentform{
|
|
|
|
|
printf("读取完毕\n");
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
}
|
|
|
|
|
void dudan2(struct studentform student[]){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void dudan2(struct studentform student[],int *studentrs1){
|
|
|
|
|
int studentrs;
|
|
|
|
|
printf("开始打开密匙\n");
|
|
|
|
|
if((fp=fopen("studentrs","rb+"))==NULL){
|
|
|
|
@ -579,15 +627,17 @@ struct studentform{
|
|
|
|
|
}
|
|
|
|
|
rewind(fp);
|
|
|
|
|
fscanf(fp,"%5d",&studentrs);
|
|
|
|
|
*studentrs1=studentrs;
|
|
|
|
|
fclose(fp);
|
|
|
|
|
int i;
|
|
|
|
|
printf("开始打开文件\n");
|
|
|
|
|
if((fp=fopen("schoolform","rb+"))==NULL){
|
|
|
|
|
if((fp=fopen("studentform","rb+"))==NULL){
|
|
|
|
|
printf("文件未能安全打开\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}else{
|
|
|
|
|
printf("文件已经安全打开了\n");
|
|
|
|
|
}
|
|
|
|
|
//printf("%d",studentrs);
|
|
|
|
|
rewind(fp); //将文件指针移到最前面
|
|
|
|
|
for(i=0;i<studentrs;i++){
|
|
|
|
|
|
|
|
|
@ -756,20 +806,20 @@ int main(){
|
|
|
|
|
switch(a1){
|
|
|
|
|
case 0:
|
|
|
|
|
printf("你选择对学校数据读档\n");
|
|
|
|
|
dudan1(school);
|
|
|
|
|
dudan1(school,&schoolgs);
|
|
|
|
|
b2=0;
|
|
|
|
|
a2=0;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
printf("你选择了对学生数据读档\n");
|
|
|
|
|
dudan2(student);
|
|
|
|
|
dudan2(student,&studentrs);
|
|
|
|
|
b1=0;
|
|
|
|
|
a2=0;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
printf("你选择了两个都读档\n");
|
|
|
|
|
dudan1(school);
|
|
|
|
|
dudan2(student);
|
|
|
|
|
dudan1(school,&schoolgs);
|
|
|
|
|
dudan2(student,&studentrs);
|
|
|
|
|
b1=0;
|
|
|
|
|
b2=0;
|
|
|
|
|
printf("都读取完毕了\n");
|
|
|
|
|