该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
getch();
fclose(fp);
}
void xiugai()
{
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("Cannot open this file.\n");
exit(0);
}
printf("\nPLease shuru xiugai xuehao:");
scanf("%d",&i); getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{
printf("xuehao:%s\nclass:%s\n",data.xuehao,data.class);
printf("Please shuru class:");
gets(data.class);
printf("Please shuru 1ci score:");
gets(temp);data.score[0]=atof(temp);
printf("Please shuru 2ci score:");
gets(temp);data.score[1]=atof(temp);
printf("Please input 3ci score:");
gets(temp);data.score[2]=atof(temp);
printf("Please input 4ci score:");
gets(temp);data.score[3]=atof(temp);
printf("Please input 5ci score:");
gets(temp);data.score[4]=atof(temp);
printf("Please shuru 6ci score:");
gets(temp);data.score[5]=atof(temp);
printf("Please shuru 7ci score:");
gets(temp);data.score[6]=atof(temp);
printf("Please shuru 8ci score:");
gets(temp);data.score[7]=atof(temp);
printf("Please shuru 9ci score:");
gets(temp);data.score[8]=atof(temp);
printf("Please shuru 10ci score:");
gets(temp);data.score[9]=atof(temp);
data.score[10]=data.score[0]+data.score[1]+data.score[2]+data.score[3]
+data.score[4]+data.score[5]+data.score[6]+data.score[7]+data.score[8]+data.score[9];
} fwrite(&data,sizeof(data),1,fp1);
}
fseek(fp,0L,0);
fseek(fp1,0L,0);
while((fread(&data,sizeof(data),1,fp1))==1)
{
fwrite(&data,sizeof(data),1,fp);
}
fclose(fp);
fclose(fp1);
}
void chazhao()
{
if((fp=fopen("s_score.txt","rb"))==NULL)
{
printf("\nCannot open this file.\n");
exit(0);
}
printf("\nPLease shuru xuehao chakan:");
scanf("%d",&i);
while(fread(&data,sizeof(data),1,fp)==1)
{
j=atoi(data.xuehao);
if(i==j)
{
printf("xuehao:%s class:%s\n 1ci:%f\n 2ci:%f\n 3ci:%f\n 4ci:%f\n 5ci:%f\n 6ci:%f\n 7ci:%f\n 8ci:%f\n 9ci:%f\n 10ci:%f\nzongfen:%f\n ",data.xuehao,data.class,data.score[0],data.score[1],data.score[2],data.score[3],
data.score[4],data.score[5],data.score[6],data.score[7],data.score[8],data.score[9],data.score[10]);
}getch();
}
}
void shanchu()
{
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("\nopen score.txt was failed!");
getch();
exit(0);
}
printf("\nPlease input ID which you want to del:");
scanf("%d",&i);getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{
printf("Anykey will delet it.\n");
getch();
continue;
}
fwrite(&data,sizeof(data),1,fp1);
}
fclose(fp);
fclose(fp1);
remove("s_score.txt");
rename("temp.txt","s_score.txt");
printf("Data delet was succesful!\n");
printf("Anykey will return to main.");
getch();
}
main()
{
while(1)
{
clrscr(); /*清屏幕*/
gotoxy(1,1); /*移动光标*/
textcolor(YELLOW); /*设置文本显示颜色为黄色*/
textbackground(BLUE); /*设置背景颜色为蓝色*/
window(1,1,99,99); /* 制作显示菜单的窗口,大小根据菜单条数设计*/
clrscr();
printf("*************welcome to use student zuoye finish manage programme***************\n");
printf("*************************menu********************************\n");
printf("* ========================================================= * \n");
printf("* 1>shuru1 2>xiugai * \n");
printf("* 3>shanchu 4>chazhao * \n");
printf("* 5>choose one class xianshi 6>exit * \n");
printf("* 0>xianshi all classes * \n");
printf("* * \n");
printf("* --------------------------------------------------------- * \n");
printf(" Please input which you want(1-6):");
ch=getch();
switch(ch)
{
case '1':shuru1();break;
case '2':xiugai(); break;
case '3':shanchu(); break;
case '4':chazhao(); break;
case '5':xianshi(); break;
case '6':exit(0); break;
case '0':xianshiall(); break;
default: continue;
}
}
}