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