杭电oj 2023

考点应该是二维数组

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	int n,m;
	while(cin >> n >> m){
	int a[55][10] = {0};//初始成绩
	int c[55] = {0};//每个学生总成绩
	int d[10] = {0};//所有科目总成绩
	int i,j;
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			cin >> a[i][j];
			c[i] += a[i][j];
			d[j] += a[i][j];
		}
	}
	int p;
	p = c[0];
	printf("%.2f",1.0*p / m);
	for(i = 1; i < n; i++){
		p = c[i];
		printf(" %.2f", 1.0*p / m);
	}
	cout << endl ;
	int q;
	q = d[0];
	printf("%.2f",1.0*q / n);
	for(j = 1; j < m; j++){
		q = d[j];
		printf(" %.2f",1.0*q / n);
	}
	cout << endl;
	int e[55] = {0};
	int count = 0;
	for(i = 0; i < n; i++){
		e[i] = 1;
		for (j = 0; j < m; j++){
			if(a[i][j] * n < d[j])e[i] = 0;
		}
		count += e[i];
	}
	cout << count << endl << endl;	//这里一定要两个换行,不然会出现PE
}
return 0;
} 
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 1024 设计师:白松林 返回首页