/*首次使用,新建score.in文件,在里面打入0
可用程序
#include
FILE *fin
main()
{
fin=fopen("score.in","r");
fprintf(fin,"0");
return 0;
}
完成
*/
#include
#include
#include
#include
#include
#define n 999
FILE *fin;
main()
{
int a[n]={0},ori=0,i=0,b=0,add[n]={0},con=0,orix[n]={0},t=0,te[n]={0},TRUEt,ixi,fx,abc=0,sum,TURE,xx;
long long f[n]={0},tex[n]={0};
printf("\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t学生成绩管理系统\n\t\t\t\t\t\t Please wait...");
Sleep(2000);system("cls");
int xp,xi;
fin=fopen("score.in","r+");
fscanf(fin,"%d",&xp);
i=xp;
for(xi=1;xi<=xp;xi++)
{fscanf(fin,"%d%d%d",&f[xi],&a[xi],&te[xi]);te[xi]--;
printf("Id:%lld score:%d ranking:%d\n",f[xi],a[xi],te[xi]+1);
add[xi]=xi;orix[xi]=a[xi];
}
fclose(fin);
int TRUE1;
pe:
while(1)
{ TRUE1=1;i++;
printf("Id(输入-1:删除,输入-2:修改成绩,输入-3:删除所有内容,输入-4:保存到score.in并退出):");
scanf("%lld",&f[i]);
for(sum=1;sumif(f[sum]==f[i])
{system("cls");for(con=1;con<=i;con++) {if(a[con]==0)continue;printf("Id:%lld score:%d ranking:%d\n",f[con],a[con],te[con]+1);}TRUE1=0;i--;printf("Error with two same id.\n");continue;}
if(TRUE1==0)
continue;
if(f[i]==-3)
{int r;
for(r=0;r
a[r]=0;ori=0;i=0;b=0;add[r]=0;con=0;orix[r]=0;t=0;te[r]=0;abc=0;
f[r]=0;tex[r]=0;
}
system("cls");
goto pe;
}
if(f[i]==-2)
{TURE=0;i--;
system("cls");
for(con=1;con<=i;con++)
{if(a[con]==0)continue; printf("Id:%lld score:%d ranking:%d\n",f[con],a[con],te[con]+1);}
printf("修改学号_____________号的分数.\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b",f[con],a[con],te[con]+1);
scanf("%d",&xx);
for(sum=1;sum<=i;sum++)
if(f[sum]==xx)
{
TURE=1;
printf("\n修改为___________.\b\b\b\b\b\b\b\b\b\b\b\b");
scanf("%d",&a[sum]);
printf("\n修改成功!将在下一次输入后更新名次。\n\n");
continue;
}
if(TURE==0)
printf("No id is %d\n",xx);
continue;
}
if(f[i]==-4)
{
i--;
fin=fopen("score.in","r+");
fprintf(fin,"%d\n",i);
for(xi=1;xi<=i;xi++)fprintf(fin,"%d %d %d\n",f[xi],a[xi],te[xi]+1);
for(xi=i+1;xi<=xp;xi++)fprintf(fin," \n");
fclose(fin);
return 0;
}
if(f[i]==-1)
{TRUEt=0;
system("cls");
i--;
for(con=1;con<=i;con++){if(a[con]==0)continue;printf("Id:%lld score:%d ranking:%d\n",f[con],a[con],te[con]+1);}
printf("删除学号_____________号.\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
scanf("%lld",&fx);
for(con=1;con<=i;con++)
if(f[con]==fx)
{TRUEt=1;abc++;
f[con]=0;
a[con]=0;
tex[abc]=te[con];
for(ixi=1;ixi<=i;ixi++)
if(te[ixi]>te[con])
te[ixi]--;
te[con]=0;
break;}
system("cls");
for(con=1;con<=i;con++){
if(a[con]==0)continue;
printf("Id:%lld score:%d ranking:%d\n",f[con],a[con],te[con]+1);}
if(TRUE==0)
printf("No Id is %lld\n",fx);
continue;
}
system("cls");
for(con=1;con{if(a[con]==0)continue; printf("Id:%lld score:%d ranking:%d\n",f[con],a[con],te[con]+1);}
printf("Id:%lld score:",f[i]);
scanf("%d",&ori);system("cls");
a[i]=ori;add[i]=i;orix[i]=a[i];
system("cls");
for(b=1;b<=i;b++)
for(con=i;con>=b;con--)
if(orix[con]>orix[con-1])
{t=orix[con];orix[con]=orix[con-1];orix[con-1]=t;
t=add[con];add[con]=add[con-1];add[con-1]=t;}
for(con=1;con<=i;con++) te[add[con]]=con;
for(con=1;con<=abc;con++)
for(ixi=1;ixi<=i;ixi++)
if(te[ixi]>tex[con])
te[ixi]--;
if(te[i]==te[i-1])te[i]=0;
for(con=1;con<=i;con++)
{if(a[con]==0)continue;printf("Id:%lld score:%d ranking:%d\n",f[con],a[con],te[con]+1);}
}
return 0;
}
//求采纳
c语言程序设计 全部按要求实现