慧咕咕 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日

悬赏问题

  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上