描述
n 位同学参加了期中考试,考试共有 m 门课程。
考试结束之后,老师想知道:每位同学有几门课程达到或超过了课程的班级平均分?
现在,请你帮忙统计一下。
输入描述
输入文件名为 count.in。
第一行,两个正整数 n,m,n 表示学生总人数,m 表示课程数量。
接下来 n 行,每行 m 个整数,表示一位同学的成绩。
输出描述
输出文件名为 count.out。
共 n 行,每行一个整数,表示该同学达到或超过平均分的课程数量。
样例输入 1
5 3 81 80 86 55 74 79 92 47 99 50 65 41 42 61 74
#include<iostream>
#include<cstdio>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
int fen[2000][21];
double zong[10000];
int ans[1000];
int main(){
int a,b;
cin>>a>>b;
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
cin>>fen[i][j];
}
}
for(int i=0;i<b;i++){
for(int j=0;j<a;j++){
zong[i]=zong[i]+fen[j][i];
}
}
for(int i=0;i<b;i++){
zong[i]=zong[i]/a;
}
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
if(fen[i][j]>=zong[j]){
ans[i]++;
}
}
}
for(int i=0;i<a;i++){
cout<<ans[i]<<endl;
}
return 0;
}
样例输出 1
3 2 2 0 0
提示
【样例说明】
3 门课程的平均分依次为:64,65.4,75.79;
5 位同学分别有 3,2,2,0,0 门课程达到或超过了课程平均分。
【数据规模】
对于 100%的数据:1<=n<=100,1<=m<=20,0<=成绩<=100。