该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
for(i=0; Stu[i].num!=-1; i++)
{ printf("\t\t No:%d %s: ",Stu[i].num,Stu[i].name);
scanf("%d",&Stu[i].score);
}
Stu[i].score=-1;
}
void Revscore(STUTYPE *Stu)
{ int iNo=0,j=0;
do
{ printf("\n\t\t Input student number(-1 end): ");
scanf("%d",&iNo);
if(iNo==-1) break;
j=0;
while(Stu[j].num!=iNo && Stu[j].num!=-1 ) j++;
if(Stu[j].num==-1)
{ printf("\t\t\t no.%d not exist. \n\n", iNo);
continue;
}
printf("\t\t no.%d %s: %d Revise: ",Stu[j].num,Stu[j].name,Stu[j].score);
scanf("%d",&Stu[j].score);
printf("\t\t no.%d %s: %d\n",Stu[j].num,Stu[j].name,Stu[j].score);
}while(1);
Showscor(Stu);
}
void Scorshow(STUTYPE *Stu)
{ int iN=0;
while(iN!=4)
{ iN=Showmenu();
switch(iN)
{ case 1: Showscor(Stu); break;
case 2: Sortshow(Stu); break;
case 3: Failname(Stu); break;
case 4: break;
default:printf("\n\t\tInput error,afresh input.");
}
if(iN!=4)
{ printf("\n\t\tPress any key to continue......");
getch();
}
}
}
int Showmenu()
{ int iNpt=0;
clrscr();
printf("\n\n\n\n\n");
printf("\t\t\t|-----------------------------------------|\n");
printf("\t\t\t| Show menu |\n");
printf("\t\t\t| ================= |\n");
printf("\t\t\t| |\n");
printf("\t\t\t| 1 --- List score |\n");
printf("\t\t\t| 2 --- List of sort |\n");
printf("\t\t\t| 3 --- list of failed |\n");
printf("\t\t\t| 4 --- Exit |\n");
printf("\t\t\t|-----------------------------------------|\n");
printf("\n\t\t\t Please select (1--4): ");
scanf("%d",&iNpt);
return iNpt;
}
void Showscor(STUTYPE *Stu)
{ int i=0;
printf("\n\t\t School report card\n");
printf("\t\t====================\n");
for(i=0; Stu[i].num!=-1; i++)
printf("\t\t No:%d %s: %d\n",Stu[i].num,Stu[i].name,Stu[i].score);
}
void Sortshow(STUTYPE *Stu)
{ int iNo=-1,iNb=0;
STUTYPE sTemp[N],stutemp={-1,'\0',-1};
do
{ iNo++;
sTemp[iNo]=Stu[iNo];
}while(Stu[iNo].num!=-1);
for(iNo=0; sTemp[iNo].num!=-1; iNo++)
for(iNb=iNo+1; sTemp[iNb].num!=-1; iNb++)
if(sTemp[iNo].score
{ stutemp=sTemp[iNo];
sTemp[iNo]=sTemp[iNb];
sTemp[iNb]=stutemp;
}
Showscor(sTemp);
}
void Failname(STUTYPE *Stu)
{ int iNo=0;
printf("\n\t\t ===== student failed report ===== \n");
while(Stu[iNo].num!=-1)
{ if(Stu[iNo].score<60)
printf("\t\t no.%d %s: %d\n",Stu[iNo].num,Stu[iNo].name,Stu[iNo].score);
iNo++;
}
}
void readstu(char *Cf,STUTYPE *Stu)
{ int i=0;
FILE *Fp=NULL;
Fp=fopen(Cf,"r");
if(Fp==NULL)
{ printf("\n\n\t\t Can not open %s file! \n",Cf);
exit(0);
}
while(feof(Fp)==0)
{ fscanf(Fp,"%d%s%d",&Stu[i].num,Stu[i].name,&Stu[i].score);
i++;
}
fclose(Fp);
}
void writestu(char *Cf,STUTYPE *Stu)
{ int i=0;
FILE *Fp=NULL;
Fp=fopen(Cf,"w");
if(Fp==NULL)
{ printf("\n\n\t\t Can not open %s file! \n",Cf);
exit(0);
}
i=-1;
do
{ i++;
fprintf(Fp,"%7d%15s%10d\n",Stu[i].num,Stu[i].name,Stu[i].score);
}while(Stu[i].num!=-1);
fclose(Fp);
}