|
|
@ -7,6 +7,7 @@
|
|
|
|
#define N 7
|
|
|
|
#define N 7
|
|
|
|
void read();
|
|
|
|
void read();
|
|
|
|
void save();
|
|
|
|
void save();
|
|
|
|
|
|
|
|
|
|
|
|
int size=3;
|
|
|
|
int size=3;
|
|
|
|
struct student
|
|
|
|
struct student
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -15,6 +16,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");
|
|
|
@ -188,6 +190,7 @@ 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)
|
|
|
@ -207,14 +210,13 @@ void defen()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void shanchu()
|
|
|
|
void shancchu()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
printf("\t************删除界面************\n");
|
|
|
|
printf("\t************删除界面************\n");
|
|
|
|
char ch1[20];
|
|
|
|
char ch1[20];
|
|
|
|
printf("原始数据:\n");
|
|
|
|
printf("原始数据:\n");
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
read();
|
|
|
|
read();
|
|
|
|
printf("输入你要删除的运动员的姓名:\n");
|
|
|
|
printf("输入你要删除的运动员的姓名:\n");
|
|
|
|
scanf("%s",&ch1);
|
|
|
|
scanf("%s",&ch1);
|
|
|
@ -261,7 +263,7 @@ void charu()
|
|
|
|
for(int i=0;i<size+1;i++)
|
|
|
|
for(int i=0;i<size+1;i++)
|
|
|
|
for(int j=i+1;j<size+1;j++)
|
|
|
|
for(int j=i+1;j<size+1;j++)
|
|
|
|
if(stu[i].scorem<stu[j].scorem)
|
|
|
|
if(stu[i].scorem<stu[j].scorem)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
temp=stu[i];
|
|
|
|
temp=stu[i];
|
|
|
|
stu[i]=stu[j];
|
|
|
|
stu[i]=stu[j];
|
|
|
|
stu[j]=temp;
|
|
|
|
stu[j]=temp;
|
|
|
@ -276,35 +278,24 @@ void charu()
|
|
|
|
void save()
|
|
|
|
void save()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FILE *fp; //定义指向文件的指针
|
|
|
|
FILE *fp; //定义指向文件的指针
|
|
|
|
|
|
|
|
|
|
|
|
if((fp=fopen("e:\\xiao.txt","w"))==NULL) //为输出打开一个二进制文件,为只写方式
|
|
|
|
if((fp=fopen("e:\\xiao.txt","w"))==NULL) //为输出打开一个二进制文件,为只写方式
|
|
|
|
{
|
|
|
|
printf("\n保存中...Saving the file......\n");
|
|
|
|
printf("打不开文件Cannot open the file\n");
|
|
|
|
|
|
|
|
return; //若打不开则返回菜单
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n保存中...Saving the file......\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()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FILE *fp;//定义指向文件的指针
|
|
|
|
FILE *fp;//定义指向文件的指针
|
|
|
|
if((fp=fopen("e:\\xiao.txt","r"))==NULL) //为输出打开一个二进制文件,为只写方式
|
|
|
|
if((fp=fopen("e:\\xiao.txt","r"))==NULL) //为输出打开一个二进制文件,为只写方式
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("打不开文件Cannot open the file\n");
|
|
|
|
|
|
|
|
return; //若打不开则返回菜单
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fscanf(fp,"运动员号码,姓名,100成绩,铅球成绩,跳高成绩,跳远成绩,系名:\n");
|
|
|
|
fscanf(fp,"运动员号码,姓名,100成绩,铅球成绩,跳高成绩,跳远成绩,系名:\n");
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -314,7 +305,7 @@ 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");
|
|
|
@ -343,7 +334,7 @@ void menu()
|
|
|
|
defen();
|
|
|
|
defen();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 6:
|
|
|
|
shanchu();
|
|
|
|
shancchu();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
case 7:
|
|
|
|
charu();
|
|
|
|
charu();
|
|
|
@ -366,6 +357,7 @@ void menu()
|
|
|
|
scanf("%2c",&ch2);
|
|
|
|
scanf("%2c",&ch2);
|
|
|
|
}while(ch2=='y');
|
|
|
|
}while(ch2=='y');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
system("color f");
|
|
|
|
system("color f");
|
|
|
|