慧咕咕 2022-11-21 12:10 采纳率: 87%
浏览 2
已结题

已有完整代码但程序运行出错

img

img


#include "com.h"
int main() {
    int total, good, failed;
    float p;
    long num[High];
    float score[High];
    total = Getscore(score, num);    //接收学生总人数
    p = Aver(score, total, num);    //接收成绩平均分
    good = Printfgood(num, score, total, p);
    failed=Printffailed(num,score, p);
    Subsection(score, total);
    return 0;
}
#include  <stdio.h>
#define High 30            //定义能输入的最多数据
#define N 6                //定义按分数分段的段数
int Getscore( float score[], long num[]);        //接收学生成绩和学号的函数
float Aver(float score[], int n, long num[]);    //计算学生成绩平均值的函数
int Printfgood(long num[], float score[], int n, float aver);    //统计并打印学生成绩在平均分及平均分以上的函数
int Printffailed(long num[], float score[], int n, float aver);  //统计并打印学生成绩不及格的函数
int Subsection(float score[], int n);            //统计各分数段所占人数及百分比的函数

#include  <stdio.h>#define High 30#include "com.h"//函数功能:接收学生成绩和学号int Getscore( float score[], long num[]) {    int i = 0;    printf("Please enter num and score until score<0:\n");    scanf("%ld %f", &num[i], &score[i]);    while (score[i] >= 0&&num[i]>0) {        i++;        scanf("%ld %f", &num[i], &score[i]);    }    printf("The total students:%d\n", i);    printf("---------------------------\n");    return i;}//函数功能:计算成绩平均分float Aver(float score[], int n, long num[]) {    float aver, sum = 0;    int  i;    for (i = 0; i < n; i++){        sum += score[i];    }    aver = sum / n;    printf("Aver=%.2f\n", aver);    printf("---------------------------\n");    return aver;}//函数功能;统计并打印输出成绩在平均分之上的学生学号和成绩int Printfgood(long num[], float score[], int n, float aver) {    int i = 0,count=0;    printf("The students above the aver:\n");    printf("The number-The scores\n");    do {        if (score[i] >= aver) {            printf("%ld,%.2f\n", num[i], score[i]);            count++;        }        i++;    } while (i < n);    printf("%d students above the aver\n",count);    printf("---------------------------\n");

  • 写回答

2条回答 默认 最新

  • hello_world&& 2022-11-21 12:28
    关注

    printffailed函数少了一个参数,应该有4个,而你在调用的时候只写了3个。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 11月29日
  • 已采纳回答 11月21日
  • 创建了问题 11月21日

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行