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