You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include"c3.cpp"
void modify() //成绩修改
{
char st[30];
double x,num;
float nu;
int k=0;
system("cls");
if((fp=fopen("a.txt","r"))==NULL)
{
printf("Cannot open the file!\n");
return;
}
while(fscanf(fp,"%lf%s%f",&s[k].no,s[k].name,&s[k].cscore)!=EOF)
{
k++;
}
fclose(fp);
printf("输入1表示用学号修改输入2表示用姓名修改请选择\n");
scanf("%lf",&x);
if(x==1)
{
printf("请输入修改成绩人的学号:");
scanf("%lf",&num);
for(int i=0;i<k;i++)
if(num==s[i].no)
{
printf("请输入修改的成绩:\n");
scanf("%f",&nu);
s[i].cscore=nu;
fp=fopen("a.txt","w");
for(i=0;i<k;i++)
fprintf(fp,"%.0lf %s %.1f\n",s[i].no,s[i].name,s[i].cscore);
fclose(fp);
printf("修改成功\n");
return;
}
printf("没有找到该生的信息!\n");
return;
}
if(x==2)
{
printf("请输入修改成绩人的姓名:");
scanf("%s",st);
for(int i=0;i<k;i++)
if(strcmp(s[i].name,st)==0)
{
printf("请输入修改的成绩:\n");
scanf("%f",&nu);
s[i].cscore=nu;
fp=fopen("a.txt","w");
for(i=0;i<k;i++)
fprintf(fp,"%.0lf %s %.1f\n",s[i].no,s[i].name,s[i].cscore);
fclose(fp);
printf("修改成功\n");
return;
}
printf("没有找到该生的信息!\n");
return;
}
}