#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");