https://pintia.cn/problem-sets/994805260223102976/problems/1071785779399028736
#include <iostream>
using namespace std;
int main(){
int max = 0, N, M, num[1001] = {0}, cnt = 0;
cin >> N >> M;
for(int i = 0; i < M; i++){
for(int j = 1; j <= N; j++){
int tmp;
cin >> tmp;
num[j] += tmp;
}
}
for(int i = 1; i <= N; i++)
if(num[i] > max)
max = num[i];
cout << max << endl;
for(int i = 1; i <= N; i++)
if(num[i] == max){
if(cnt)
cout << " ";
cout << i;
cnt++;
}
return 0;
}

本文提供了一个使用C++编程语言实现的简单程序,该程序能够接收N个数的M次输入,并计算出每个位置上的数的最大值及其对应的位置。通过遍历二维数组并比较元素值的方式找到最大值。
742

被折叠的 条评论
为什么被折叠?



