囧男孩
来我空间,我这有啊!865475739/* Note:Your choice is C IDE */#include <stdio.h> struct Student { int num; char name[20]; float score[3]; float avg; }stus[30]; void Add(float*);/*填加学员*/ void List();/*/学员详细列表 */void Asc();/*/显示后三名学员 */void Desc();/*/显示前三名学员*/ void Display(); void main() { int s; float xxx;while(1) { printf("Students System:\n"); printf("1. Add Student\n"); printf("2. Student list\n"); printf("3. Display the before Three\n"); printf("4. Display the last three NUm\n"); printf("5. Display the average\n"); printf("6. Exit\n"); printf("Please input select:\t");scanf("%d",&s); switch(s) { case 1: Add(&xxx); break; case 2: List(); break; case 3: Desc(); Display(); break; case 4: Asc(); Display(); break; case 5: Display(); break; case 6: return; break; default: printf("Select Wrong!\n"); break; } } } void Add(float* p) { int i,k; float sum; char c; for(i=0;i<30;i++) { printf("Input the num %d student Information:\n",i+1); printf("Num:"); scanf("%d",&stus[i].num); printf("Name:"); fflush(stdin); scanf("%s",stus[i].name); printf("Please the before three chenji:\n"); sum=0; for(k=0;k<3;k++) { printf("%d:",k+1); scanf("%f",p);stus[i].score[k]=*p; sum+=stus[i].score[k]; } stus[i].avg=sum/3; printf("Is go on?"); fflush(stdin); scanf("%c",&c); if(c=='n' || c=='N') return; } } void List() { int i,j=0; printf("Num\tName\tChenji1\tChenji2\tChenji3\tAverage\n"); for(i=0;i<30;i++) { if(stus[i].num!=0) { printf("%d\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n",stus[i].num,stus[i].name,stus[i].score[0],stus[i].score[1],stus[i].score[2],stus[i].avg); } } } void Asc() { int i,j; struct Student c; for(i=0;i<30;i++) { for(j=0;j<29-i;j++) if(stus[j].avg<stus[j+1].avg) { c=stus[j]; stus[j]=stus[j+1]; stus[j+1]=c; } } } void Desc() { int i,j; struct Student c; for(i=0;i<30;i++) { for(j=0;j<29-i;j++) if(stus[j].avg>stus[j+1].avg) { c=stus[j]; stus[j]=stus[j+1]; stus[j+1]=c; } } } void Display() { int i,d=0; printf("Num\tName\tAverage\n"); for(i=0;i<30;i++) { if(stus[i].num!=0) { printf("%d\t%s\t%.2f\n",stus[i].num,stus[i].name,stus[i].avg); d++; } if(d==3) break; } } 在楼上的这位基础上稍候修改了一下,因为其在TC中不能正常编译.......不是这种的 我在网上已经看到了 要以这个#include开始c++的代码