|
|
@ -7,7 +7,6 @@
|
|
|
|
#define N 7
|
|
|
|
#define N 7
|
|
|
|
void read();
|
|
|
|
void read();
|
|
|
|
void save();
|
|
|
|
void save();
|
|
|
|
|
|
|
|
|
|
|
|
int size=3;
|
|
|
|
int size=3;
|
|
|
|
struct student
|
|
|
|
struct student
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -16,8 +15,7 @@ struct student
|
|
|
|
int scorem,scoreq,scoreg,scorey;
|
|
|
|
int scorem,scoreq,scoreg,scorey;
|
|
|
|
char ximing[20];
|
|
|
|
char ximing[20];
|
|
|
|
}stu[N],temp;
|
|
|
|
}stu[N],temp;
|
|
|
|
|
|
|
|
void input()
|
|
|
|
void input() //输入原始数据//
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
printf("\t************输入界面************\n");
|
|
|
|
printf("\t************输入界面************\n");
|
|
|
@ -28,7 +26,7 @@ void input() //
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
printf("%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);
|
|
|
|
printf("%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void find() //查找函数//
|
|
|
|
void find()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
printf("\t************查找界面************\n");
|
|
|
|
printf("\t************查找界面************\n");
|
|
|
@ -60,7 +58,7 @@ void find() //
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void paixu() //排序函数//
|
|
|
|
void paixu()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
printf("\t************排序界面************\n");
|
|
|
|
printf("\t************排序界面************\n");
|
|
|
@ -81,7 +79,7 @@ void paixu() //
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
printf("%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);
|
|
|
|
printf("%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void xiugai() //修改函数//
|
|
|
|
void xiugai()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
printf("\t************修改界面************\n");
|
|
|
|
printf("\t************修改界面************\n");
|
|
|
@ -90,8 +88,6 @@ void xiugai() //
|
|
|
|
int scorem,scoreq,scoreg,scorey,i;
|
|
|
|
int scorem,scoreq,scoreg,scorey,i;
|
|
|
|
char ximing[20];
|
|
|
|
char ximing[20];
|
|
|
|
printf("原始数据:\n");
|
|
|
|
printf("原始数据:\n");
|
|
|
|
/*for(int i=0;i<size;i++)
|
|
|
|
|
|
|
|
printf("%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);*/
|
|
|
|
|
|
|
|
read();
|
|
|
|
read();
|
|
|
|
printf("输入你要修改运动员的姓名:");
|
|
|
|
printf("输入你要修改运动员的姓名:");
|
|
|
|
scanf("%s",ch2);
|
|
|
|
scanf("%s",ch2);
|
|
|
@ -161,15 +157,13 @@ void xiugai() //
|
|
|
|
}
|
|
|
|
}
|
|
|
|
save();
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void defen() //得分函数
|
|
|
|
void defen()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
printf("\t************得分界面************\n");
|
|
|
|
printf("\t************得分界面************\n");
|
|
|
|
int x,y,z,w,o,p,q,i;
|
|
|
|
int x,y,z,w,o,p,q,i;
|
|
|
|
char ch1[20]="jisuanji",ch2[20]="tumu",ch3[20]="yejin";
|
|
|
|
char ch1[20]="jisuanji",ch2[20]="tumu",ch3[20]="yejin";
|
|
|
|
printf("原始数据:\n");
|
|
|
|
printf("原始数据:\n");
|
|
|
|
/*for(int i=0;i<size;i++)
|
|
|
|
|
|
|
|
printf("%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);*/
|
|
|
|
|
|
|
|
read();
|
|
|
|
read();
|
|
|
|
printf("各系的得分总分排序:\n");
|
|
|
|
printf("各系的得分总分排序:\n");
|
|
|
|
for(i=0;i<size;i++)
|
|
|
|
for(i=0;i<size;i++)
|
|
|
@ -194,7 +188,6 @@ void defen() //
|
|
|
|
else if(stu[i].scorey==3) w=1;
|
|
|
|
else if(stu[i].scorey==3) w=1;
|
|
|
|
else w=0;
|
|
|
|
else w=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(i=0;i<size;i++)
|
|
|
|
for(i=0;i<size;i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(strcmp(stu[i].ximing,ch1)==0)
|
|
|
|
if(strcmp(stu[i].ximing,ch1)==0)
|
|
|
@ -214,15 +207,14 @@ void defen() //
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void shancchu()//删除函数//
|
|
|
|
void shanchu()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
printf("\t************删除界面************\n");
|
|
|
|
printf("\t************删除界面************\n");
|
|
|
|
char ch1[20];
|
|
|
|
char ch1[20];
|
|
|
|
printf("原始数据:\n");
|
|
|
|
printf("原始数据:\n");
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
/*for(int i=0;i<size;i++)
|
|
|
|
|
|
|
|
printf("%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);*/
|
|
|
|
|
|
|
|
read();
|
|
|
|
read();
|
|
|
|
printf("输入你要删除的运动员的姓名:\n");
|
|
|
|
printf("输入你要删除的运动员的姓名:\n");
|
|
|
|
scanf("%s",&ch1);
|
|
|
|
scanf("%s",&ch1);
|
|
|
@ -242,7 +234,7 @@ void shancchu()//ɾ
|
|
|
|
}size--;
|
|
|
|
}size--;
|
|
|
|
save();
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void charu() //插入函数
|
|
|
|
void charu()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
int a;
|
|
|
|
int a;
|
|
|
@ -281,22 +273,20 @@ void charu() //
|
|
|
|
printf("%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);
|
|
|
|
printf("%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);
|
|
|
|
save();
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void save() //保存数据到文件函数
|
|
|
|
void save()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FILE *fp; //定义指向文件的指针
|
|
|
|
FILE *fp; //定义指向文件的指针
|
|
|
|
//char outfile[20];
|
|
|
|
|
|
|
|
//printf("输出文件例如:c:\\score Enter outfile name,for example c:\\score\n");
|
|
|
|
|
|
|
|
//scanf("%s",outfile);
|
|
|
|
|
|
|
|
if((fp=fopen("e:\\xiao.txt","w"))==NULL) //为输出打开一个二进制文件,为只写方式
|
|
|
|
if((fp=fopen("e:\\xiao.txt","w"))==NULL) //为输出打开一个二进制文件,为只写方式
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("打不开文件Cannot open the file\n");
|
|
|
|
printf("打不开文件Cannot open the file\n");
|
|
|
|
return; //若打不开则返回菜单
|
|
|
|
return; //若打不开则返回菜单
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("\n保存中...Saving the file......\n");
|
|
|
|
printf("\n保存中...Saving the file......\n");
|
|
|
|
//fprintf(fp,"运动员号码,姓名,100成绩,铅球成绩,跳高成绩,跳远成绩,系名:\n");
|
|
|
|
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
fprintf(fp,"%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);
|
|
|
|
fprintf(fp,"%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);
|
|
|
|
fclose(fp); //关闭文件
|
|
|
|
fclose(fp);
|
|
|
|
printf("保存成功....Save the file successfully!\n");
|
|
|
|
printf("保存成功....Save the file successfully!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void read()
|
|
|
|
void read()
|
|
|
@ -314,13 +304,8 @@ void read()
|
|
|
|
fscanf(fp,"%s\t%s\t%d\t%d\t%d\t%d\t%s\n",&stu[i].num,&stu[i].name,&stu[i].scorem,&stu[i].scoreq,&stu[i].scoreg,&stu[i].scorey,&stu[i].ximing);
|
|
|
|
fscanf(fp,"%s\t%s\t%d\t%d\t%d\t%d\t%s\n",&stu[i].num,&stu[i].name,&stu[i].scorem,&stu[i].scoreq,&stu[i].scoreg,&stu[i].scorey,&stu[i].ximing);
|
|
|
|
printf("%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);
|
|
|
|
printf("%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp); //关闭文件
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void menu()
|
|
|
|
void menu()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int ch1;
|
|
|
|
int ch1;
|
|
|
@ -329,9 +314,8 @@ void menu()
|
|
|
|
time_t t;
|
|
|
|
time_t t;
|
|
|
|
t=time(NULL);
|
|
|
|
t=time(NULL);
|
|
|
|
pt=localtime(&t); /*读取系统日期并把它放到结构体中*/
|
|
|
|
pt=localtime(&t); /*读取系统日期并把它放到结构体中*/
|
|
|
|
|
|
|
|
|
|
|
|
do{
|
|
|
|
do{
|
|
|
|
printf("\t\t当前系统日期:%d-%d-%d\n",pt->tm_year+1900,pt->tm_mon+1,pt->tm_mday); /*显示当前系统日期*/
|
|
|
|
printf("\t\t当前系统日期:%d-%d-%d\n",pt->tm_year+1900,pt->tm_mon+1,pt->tm_mday);
|
|
|
|
printf("======================菜单=====================\n");
|
|
|
|
printf("======================菜单=====================\n");
|
|
|
|
printf(" 1.输入 2.查找 \n");
|
|
|
|
printf(" 1.输入 2.查找 \n");
|
|
|
|
printf(" 3.排序 4.修改 \n");
|
|
|
|
printf(" 3.排序 4.修改 \n");
|
|
|
@ -339,8 +323,7 @@ void menu()
|
|
|
|
printf(" 7.插入 8.保存 \n");
|
|
|
|
printf(" 7.插入 8.保存 \n");
|
|
|
|
printf(" 9.显示 0.退出\n");
|
|
|
|
printf(" 9.显示 0.退出\n");
|
|
|
|
printf("===============================================\n");
|
|
|
|
printf("===============================================\n");
|
|
|
|
printf("请选择功能<1-8>:[ ]\b\b");
|
|
|
|
printf("请选择功能<0-9>:[ ]\b\b");
|
|
|
|
//getchar();
|
|
|
|
|
|
|
|
scanf("%d",&ch1);
|
|
|
|
scanf("%d",&ch1);
|
|
|
|
switch(ch1)
|
|
|
|
switch(ch1)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -360,7 +343,7 @@ void menu()
|
|
|
|
defen();
|
|
|
|
defen();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 6:
|
|
|
|
shancchu();
|
|
|
|
shanchu();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
case 7:
|
|
|
|
charu();
|
|
|
|
charu();
|
|
|
@ -381,12 +364,11 @@ void menu()
|
|
|
|
printf("想要继续操作请按y\n");
|
|
|
|
printf("想要继续操作请按y\n");
|
|
|
|
getchar();
|
|
|
|
getchar();
|
|
|
|
scanf("%2c",&ch2);
|
|
|
|
scanf("%2c",&ch2);
|
|
|
|
}while(ch2=='y'); //条件判断
|
|
|
|
}while(ch2=='y');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
system("color 3f");
|
|
|
|
system("color f");
|
|
|
|
//Logon();
|
|
|
|
//Logon();
|
|
|
|
menu();
|
|
|
|
menu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|