|
|
|
@ -26,6 +26,10 @@
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
#include<string.h>
|
|
|
|
|
#include<process.h>
|
|
|
|
|
#include<conio.h>
|
|
|
|
|
|
|
|
|
|
FILE *fp; //定义文件指针
|
|
|
|
|
|
|
|
|
|
struct xmform1{
|
|
|
|
|
char name[20];
|
|
|
|
@ -46,7 +50,7 @@ struct schoolform{
|
|
|
|
|
char name[20];
|
|
|
|
|
char id[10];
|
|
|
|
|
int number;
|
|
|
|
|
int scoer;
|
|
|
|
|
int scoer=0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct studentform{
|
|
|
|
@ -84,10 +88,42 @@ struct studentform{
|
|
|
|
|
gets(student[i].xm.name);
|
|
|
|
|
printf("当前一记录%d个学生的数据\n",i+1);
|
|
|
|
|
}
|
|
|
|
|
printf("输入结束\n");
|
|
|
|
|
printf("信息输入结束\n");
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
printf("是否对当前信息进行存档,按'y'表示是\n");
|
|
|
|
|
char next;
|
|
|
|
|
next=getch();
|
|
|
|
|
if(next=='y'){
|
|
|
|
|
//printf("开始打开文件\n");
|
|
|
|
|
//if((fp=fopen("studentform","rb+"))==NULL){
|
|
|
|
|
printf("开始创造文件\n");
|
|
|
|
|
if((fp=fopen("studentform","wb+"))==NULL){
|
|
|
|
|
printf("文件创造未成功\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}else{
|
|
|
|
|
printf("文件创造成功\n");
|
|
|
|
|
}
|
|
|
|
|
//}else{
|
|
|
|
|
//printf("文件已打开,并开始存储信息\n");
|
|
|
|
|
//}
|
|
|
|
|
printf("开始存储信息\n");
|
|
|
|
|
for(i=0;i<n;i++){
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
printf("开始创造打开密匙\n");
|
|
|
|
|
if((fp=fopen("studentrs","wb+"))==NULL){
|
|
|
|
|
printf("打开密匙创造未成功\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}else{
|
|
|
|
|
printf("打开密匙创造成功\n");
|
|
|
|
|
}
|
|
|
|
|
fprintf(fp,"%5d",n);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
int ggy1(struct schoolform school[]){
|
|
|
|
|
printf("请输入参加比赛的学校个数\n");
|
|
|
|
|
int n;
|
|
|
|
@ -104,10 +140,46 @@ struct studentform{
|
|
|
|
|
getchar();
|
|
|
|
|
printf("当前一共记录了%d学校的数据\n",i+1);
|
|
|
|
|
}
|
|
|
|
|
printf("输入结束\n");
|
|
|
|
|
printf("信息输入结束\n");
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
printf("是否对当前信息进行存档,按'y'表示是\n");
|
|
|
|
|
char next;
|
|
|
|
|
next=getch();
|
|
|
|
|
if(next=='y'){
|
|
|
|
|
//printf("开始打开文件\n");
|
|
|
|
|
//if((fp=fopen("schoolform","rb+"))==NULL){
|
|
|
|
|
printf("开始创造文件\n");
|
|
|
|
|
if((fp=fopen("schoolform","wb+"))==NULL){
|
|
|
|
|
printf("文件创造未成功\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}else{
|
|
|
|
|
printf("文件创造成功\n");
|
|
|
|
|
}
|
|
|
|
|
//}else{
|
|
|
|
|
//printf("文件已打开,并开始存储信息\n");
|
|
|
|
|
//}
|
|
|
|
|
printf("开始存储信息\n");
|
|
|
|
|
for(i=0;i<n;i++){
|
|
|
|
|
|
|
|
|
|
fprintf(fp,"%10s%10s%3d",school[i].name,school[i].id,school[i].number);
|
|
|
|
|
}
|
|
|
|
|
printf("存储完成\n");
|
|
|
|
|
fclose(fp);
|
|
|
|
|
printf("开始创造打开密匙\n");
|
|
|
|
|
if((fp=fopen("schoolgs","wb+"))==NULL){
|
|
|
|
|
printf("打开密匙创造未成功\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}else{
|
|
|
|
|
printf("打开密匙创造成功\n");
|
|
|
|
|
}
|
|
|
|
|
fprintf(fp,"%5d",n);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ggy2(struct xmform1 xm1[],struct studentform student[],struct schoolform school[],int schoolgs,int studentrs){
|
|
|
|
|
printf("请输入这一类项目的个数:\n");
|
|
|
|
|
int n;
|
|
|
|
@ -297,7 +369,7 @@ struct studentform{
|
|
|
|
|
if(a==0){
|
|
|
|
|
printf("将依次输出该选手信息:\n");
|
|
|
|
|
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);
|
|
|
|
|
printf("所属学校:%s 参加项目名称:%s 名次:%s 总分数:%d \n",student[i].name1,student[i].xm.name,student[i].xm.mc,student[i].xm.scoer);
|
|
|
|
|
a1=1; //防止有些选手信息未记录而找不到
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -384,7 +456,7 @@ struct studentform{
|
|
|
|
|
a=strcmp(school[i].name,name);
|
|
|
|
|
if(a==0){
|
|
|
|
|
printf("将依次输出该学校信息:\n");
|
|
|
|
|
printf("名称:%s 编号:%s 参赛人数:%d 总分数:%s \n",school[i].name,school[i].id,school[i].number,school[i].scoer);
|
|
|
|
|
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; //防止有些选手信息未记录而找不到
|
|
|
|
|
break;
|
|
|
|
@ -406,7 +478,7 @@ struct studentform{
|
|
|
|
|
a=strcmp(school[i].id,number);
|
|
|
|
|
if(a==0){
|
|
|
|
|
printf("将依次输出该选学校信息:\n");
|
|
|
|
|
printf("名称:%s 编号:%s 参赛人数:%d 总分数:%s \n",school[i].name,school[i].id,school[i].number,school[i].scoer);
|
|
|
|
|
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; //防止有些选手信息未记录而找不到
|
|
|
|
|
break;
|
|
|
|
@ -468,9 +540,68 @@ struct studentform{
|
|
|
|
|
}
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
}
|
|
|
|
|
void dudan1(struct schoolform school[]){
|
|
|
|
|
int schoolgs;
|
|
|
|
|
printf("开始打开密匙\n");
|
|
|
|
|
if((fp=fopen("schoolgs","rb+"))==NULL){
|
|
|
|
|
printf("密匙未能安全打开\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}else{
|
|
|
|
|
printf("密匙已经安全打开了\n");
|
|
|
|
|
}
|
|
|
|
|
rewind(fp);
|
|
|
|
|
fscanf(fp,"%5d",&schoolgs);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
int i;
|
|
|
|
|
printf("开始打开文件\n");
|
|
|
|
|
if((fp=fopen("schoolform","rb+"))==NULL){
|
|
|
|
|
printf("文件未能安全打开\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}else{
|
|
|
|
|
printf("文件已经安全打开了\n");
|
|
|
|
|
}
|
|
|
|
|
rewind(fp); //将文件指针移到最前面
|
|
|
|
|
for(i=0;i<schoolgs;i++){
|
|
|
|
|
|
|
|
|
|
fscanf(fp,"%10s%10s%3d",school[i].name,school[i].id,&school[i].number);
|
|
|
|
|
}
|
|
|
|
|
printf("读取完毕\n");
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
}
|
|
|
|
|
void dudan2(struct studentform student[]){
|
|
|
|
|
int studentrs;
|
|
|
|
|
printf("开始打开密匙\n");
|
|
|
|
|
if((fp=fopen("studentrs","rb+"))==NULL){
|
|
|
|
|
printf("密匙未能安全打开\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}else{
|
|
|
|
|
printf("密匙已经安全打开了\n");
|
|
|
|
|
}
|
|
|
|
|
rewind(fp);
|
|
|
|
|
fscanf(fp,"%5d",&studentrs);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
int i;
|
|
|
|
|
printf("开始打开文件\n");
|
|
|
|
|
if((fp=fopen("schoolform","rb+"))==NULL){
|
|
|
|
|
printf("文件未能安全打开\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}else{
|
|
|
|
|
printf("文件已经安全打开了\n");
|
|
|
|
|
}
|
|
|
|
|
rewind(fp); //将文件指针移到最前面
|
|
|
|
|
for(i=0;i<studentrs;i++){
|
|
|
|
|
|
|
|
|
|
fscanf(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");
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(){
|
|
|
|
|
system("cls"); //清屏
|
|
|
|
|
system("color 2F"); //调程序颜色背景 (护眼)
|
|
|
|
|
printf("<<**********欢迎来到运动会比赛计分系统**********>>\n");
|
|
|
|
|
printf("此系统有以下功能选项:\n");
|
|
|
|
|
|
|
|
|
@ -485,12 +616,29 @@ int main(){
|
|
|
|
|
char name[10];
|
|
|
|
|
int a,a1,a2; //a2为方便switch退出时用的字符
|
|
|
|
|
int i;
|
|
|
|
|
int b1=1,b2=1; ///b1和b2作为“锁”必须对程序进行初始化输入才能解开
|
|
|
|
|
//scanf("%d",&a);
|
|
|
|
|
do{
|
|
|
|
|
printf("输入选手信息(请按0)\n输入学校信息(请按1)\n输入项目信息(请按2)\n寻找并输出选手信息(请按3)\n寻找并输出项目信息(请按4)\n寻找并输出学校信息(请按5)\n学校排行输出(请按6)\n参赛选手排行输出(请按7)\n");
|
|
|
|
|
printf("退出(请按8)\n");
|
|
|
|
|
printf("提示:赛前请对程序进行基本信息的输入(1.即完成选手信息的输入和学校信息的输入2.对选手信息和学校信息读档 )\n");
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
printf("输入选手信息并存档(请按0)\n输入学校信息并存档(请按1)\n输入项目信息(请按2)\n寻找并输出选手信息(请按3)\n寻找并输出项目信息(请按4)\n寻找并输出学校信息(请按5)\n学校排行输出(请按6)\n参赛选手排行输出(请按7)\n");
|
|
|
|
|
printf("读档(请按8)\n");
|
|
|
|
|
printf("退出(请按9)\n");
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
scanf("%d",&a);
|
|
|
|
|
do{
|
|
|
|
|
if(a==0||a==1||a==8||a==9) { break ;}
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
|
|
if(b1==0&&b2==0){ break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
printf("请先完成程序初始化操作(按提示先操作)\n");
|
|
|
|
|
printf("********************\n");
|
|
|
|
|
printf("请重新按一次(0、1、8)\n");
|
|
|
|
|
scanf("%d",&a);
|
|
|
|
|
}}}while(1);
|
|
|
|
|
switch(a){
|
|
|
|
|
case 0:
|
|
|
|
|
//struct studentform student[50];
|
|
|
|
@ -499,11 +647,13 @@ int main(){
|
|
|
|
|
//int n;
|
|
|
|
|
//scanf("%d",&n);
|
|
|
|
|
studentrs=ggy(student);
|
|
|
|
|
b1=0 ;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
//struct schoolform school[10];
|
|
|
|
|
printf("你选择了输入学校信息功能\n");
|
|
|
|
|
schoolgs=ggy1(school);
|
|
|
|
|
b2=0;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
printf("你选择了输入项目信息功能\n");
|
|
|
|
@ -597,10 +747,47 @@ int main(){
|
|
|
|
|
studentph(student,studentrs);
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
printf("你选择了读档功能\n");
|
|
|
|
|
printf("请选择对:学校数据读档(请按0) 学生数据读档(请按1) 两个都读档(请按2)\n");
|
|
|
|
|
scanf("%d",&a1);
|
|
|
|
|
getchar();
|
|
|
|
|
a2=1;
|
|
|
|
|
do{
|
|
|
|
|
switch(a1){
|
|
|
|
|
case 0:
|
|
|
|
|
printf("你选择对学校数据读档\n");
|
|
|
|
|
dudan1(school);
|
|
|
|
|
b2=0;
|
|
|
|
|
a2=0;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
printf("你选择了对学生数据读档\n");
|
|
|
|
|
dudan2(student);
|
|
|
|
|
b1=0;
|
|
|
|
|
a2=0;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
printf("你选择了两个都读档\n");
|
|
|
|
|
dudan1(school);
|
|
|
|
|
dudan2(student);
|
|
|
|
|
b1=0;
|
|
|
|
|
b2=0;
|
|
|
|
|
printf("都读取完毕了\n");
|
|
|
|
|
a2=0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("请输入(0~2)以内的数\n");
|
|
|
|
|
scanf("%d",&a1);
|
|
|
|
|
getchar();
|
|
|
|
|
}
|
|
|
|
|
}while(a2);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 9:
|
|
|
|
|
printf("成功退出,感谢使用!\n");
|
|
|
|
|
return 0;
|
|
|
|
|
default:
|
|
|
|
|
printf("请按(0~8)以内的数字\n");
|
|
|
|
|
printf("请按(0~9)以内的数字\n");
|
|
|
|
|
}
|
|
|
|
|
}while(1);
|
|
|
|
|
return 0;
|
|
|
|
|