在这里插入代码片
#include<iostream>
using namespace std;
int main()
{
int arr[5][5]{
{1,2,3,4,5},
{2,3,4,5,6},
{3,4,5,6,7},
{1,1,1,1,1},
{2,2,2,2,2}
};
int arr2[5];
for (int i = 0; i < 5; i++) {
int sum = 0;
for (int j = 0; j < 5; j++) {
sum += arr[i][j];
}
arr2[i] = sum;
}
int max = arr2[0];
for (int i = 0; i < 5; i++) {
if (max < arr2[i]) {
max = arr2[i];
}
}
int t[3][5];
for (int i = 0; i < 5; i++) {
if (max == arr2[i]) {
for (int j = 0; j < 5;j++) {
t[0][j] = arr[0][j];
arr[0][j] = arr[i][j];
arr[i][j] = t[0][j];
}
}
}
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
cout << arr[i][j];
}
cout << endl;
}
return 0;
}