|  | 
 
| 
编写:输入10个学生的3门课的成绩,分别用函数求:
x
马上注册,结交更多好友,享用更多功能^_^您需要 登录 才可以下载或查看,没有账号?立即注册  (1)        每个学生的平均分。
 (2)        每门课的平均分。
 (3)        按学生平均分降序排列输出学生信息。
 (4)        统计不及格学生,输出其相应信息。
 (5)        编写一菜单主函数,菜单内容包括以上4部分。
 分析:本题要求完成的操作有录入数据、求平均分、排序、统计。这些操作分别用函数来实现。先分析表示这些数据的数据结构,可用如下结构来表示学生的成绩:
 课程1        课程2        课程3        平均分
 68        74        50
 …        …        …
 即10个学生的3门课程成绩可以登记在一个二维数组中score[10][4],其中最后一列用于保存平均分,学生的学号不单独记录,学生的序号用二维表的行号来表示。下面给出了主菜单的参考程序c60205.c,其他功能的函数学生自己编写。
 #include <stdio.h>
 #define N 10
 #define M 4
 void main()
 {
 int score[N][M];
 char  choice='1';
 void input(int [][],int,int);
 void aver_stu(int [][],int,int);
 void aver_cour(int [][],int,int);
 void orde_aver(int [][],int,int);
 void failed(int [][],int,int);
 
 input(score,N,M);
 /*显示主菜单*/
 while(choice!='0')
 {
 clrscr();
 printf(" ==========the Score Processing System ===============\n");
 printf("1.print each student's average\n");
 printf("2.print each course's average\n");
 printf("3.Order the students by student's average decreasingly \n");
 printf("4.print the failed student \n");
 printf("0.Exit the system \n");
 printf("==============================================\n");
 printf("Please choise (0-4): \n");
 choice=getchar();
 switch(choice)
 {
 case '1':aver_stu(score,N,M); break;
 case '2':aver_cour(score,N,M); break;
 case '3':orde_aver(score,N,M); break;
 case '4':failed(score,N,M); break;
 case '0':exit(0);
 default:printf("Choice Error,Please select again(0-4).");
 }
 }
 }
 
 | 
 |