c#include #include #defineN3//课程门数#defineM3//学生人数main(){inti,j,choice,person,course;intsum[10],score[M][10];floatave[M];charno[M][10],name[M][10],subject[N][20],temp[10];for(;;){printf("选项:\n");printf("1、输入数据\n");printf("2、输出成绩(在输入成绩前不能选择该选项)\n");printf("3、查找(在输入成绩前不能选择该选项)\n");printf("4、排序(在输入成绩前不能选择该选项)\n");printf("0、退出\n");printf("\n您的选择是:");scanf("%d",&choice);switch(choice){case1:do{printf("请输入学生数[<=%d]:",M);scanf("%d",&person);}while(person<0||person>M);do{printf("请输入课程数[<=%d]:",N);scanf("%d",&course);}while(course<0||course>N);for(j=0;j{ printf("请输入第%d门课程名称:",j+1);scanf("%s",subject[j]);}for(i=0;i{ sum[i]=0;printf("\n请输入第%d名学生的学号:",i+1);fflush(stdin);//清空缓冲区里的字符scanf("%s",no[i]);printf("\n请输入第%d名学生的姓名:",i+1);fflush(stdin);scanf("%s",name[i]);printf("\n\n请输入%-s号学生成绩:\n",no[i]);ave[i]=0;sum[i]=0;for(j=0;j{ printf("\n请输入%s的%s成绩:",no[i],subject[j]);scanf("%d",&score[i][j]);sum[i]=sum[i]+score[i][j];}ave[i]=1.0*sum[i]/course;}break;case2:printf("\n\nNo");for(i=0;iprintf("%10s",subject[i]); printf("Average");printf("\n----------------------------------------------------\n");for(i=0;i{ printf("%-10s",no[i]);for(j=0;jprintf("%3d",score[i][j]); printf("%-6.1f\n",ave[i]);}case3:printf("请输入要查找的学生学号:");scanf("%s",&temp);for(i=0;i{ if(strcmp(no[i],temp)==0){printf("查找结果如下\n\n");printf("No");for(i=0;iprintf("%10s",subject[i]); printf("Average");printf("\n----------------------------------------------------\n");printf("%-10s",no[i]);for(j=0;jprintf("%3d",score[i][j]); printf("%-6.1f\n",ave[i]);}}break;case4:break;}}}
吃鸡游戏
相关分类