C语言 指针方法 有一个班4个学生,5门课程

有一个班4个学生,5门课程。一:求第1门课程的平均分;二:找出有两门以上课程不及格的学生,输出他们的学号和全部课程成绩及平均成绩;三:找出平均成绩在90分以上或全部课程成绩在85分以上的学生。分别编3个函数实现以上3个要求。

#include <stdio.h>

#define NUM_STUDENTS 4
#define NUM_COURSES 5

void averageFirstCourse(int scores[NUM_STUDENTS][NUM_COURSES]) {
    double total = 0;
    for (int i = 0; i < NUM_STUDENTS; i++) {
        total += scores[i][0];
    }
    printf("Average score of the first course: %f\n", total / NUM_STUDENTS);
}

void findFailingStudents(int scores[NUM_STUDENTS][NUM_COURSES]) {
    for (int i = 0; i < NUM_STUDENTS; i++) {
        int failCount = 0;
        for (int j = 0; j < NUM_COURSES; j++) {
            if (scores[i][j] < 60) {
                failCount++;
            }
        }
        if (failCount >= 2) {
            printf("Student %d failed in %d courses. Scores: ", i + 1, failCount);
            doubl

相关推荐

  1. C语言 指针方法 一个4学生5课程

    2024-07-22 19:56:03       13 阅读
  2. C语言--指针4

    2024-07-22 19:56:03       32 阅读
  3. C语言.指针4

    2024-07-22 19:56:03       30 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-22 19:56:03       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-22 19:56:03       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-22 19:56:03       45 阅读
  4. Python语言-面向对象

    2024-07-22 19:56:03       55 阅读

热门阅读

  1. C++中的explicit关键字

    2024-07-22 19:56:03       13 阅读
  2. 数组常见的实例方法

    2024-07-22 19:56:03       15 阅读
  3. 精通Gradle发布配置:打造自动化部署的高速公路

    2024-07-22 19:56:03       16 阅读
  4. 力扣283.移动零

    2024-07-22 19:56:03       15 阅读
  5. SAP 如何修改统驭科目类型

    2024-07-22 19:56:03       15 阅读
  6. 部署Mojo模型:生产环境中的智能自动化

    2024-07-22 19:56:03       15 阅读
  7. Linux的shell的date命令

    2024-07-22 19:56:03       15 阅读
  8. Haproxy

    Haproxy

    2024-07-22 19:56:03      15 阅读
  9. 免费云服务器

    2024-07-22 19:56:03       18 阅读
  10. 智慧文元宇宙

    2024-07-22 19:56:03       14 阅读