鱼C论坛

 找回密码
 立即注册
查看: 2513|回复: 4

一道C语言作业题,蛮急,求解

[复制链接]
发表于 2016-12-11 22:54:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
编写:输入10个学生的3门课的成绩,分别用函数求:
(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).");
                }
        }
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2016-12-12 01:15:46 | 显示全部楼层
是想让大家帮你写吗?

你好歹自己写一两行啊……
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-12-12 23:05:46 | 显示全部楼层
四十二 发表于 2016-12-12 01:15
是想让大家帮你写吗?

你好歹自己写一两行啊……

void input(int score[][])
{
        int i,j;
        for(i=0;i<N;i++)
        {
                printf("\n input score of student %2d:\n",i+1);
                for(j=0;j<M;j++)
                        scanf("%f",&score[j]);
        }
}

void aver_stu(int score[][])
{
        int i,j;
        float s;
        for(i=0;i<N;i++)
        {
                for(j=0;j<M;j++)
                {
                        s=0;
                        for(i=0;i<N;i++)
                                s+=score[j];
                        a_stu=s/3.0;
                        printf("aver_stu[%d]=%8.2f",i,a_stu);
                }
        }
}

void aver_cour(int score[][])
{
        int i,j;
        float s;
        for(j=0;j<M;j++)
        {
                s=0;
                for(i=0;i<N;i++)
                        s+=score[j];
                a_cour[j]=s/(float)N;
                printf("aver_cour[%d]=%8.2f",j,a_cour[j]);
        }
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-12-12 23:06:26 | 显示全部楼层
四十二 发表于 2016-12-12 01:15
是想让大家帮你写吗?

你好歹自己写一两行啊……

我写了,可是貌似是错的
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2016-12-13 11:56:45 | 显示全部楼层
你这编程习惯很不好啊 你要在你声明的函数后面注释你这函数是干什么用的
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-27 19:24

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表