Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C++ program: Given an integer matrix, please find the maximum value of each row row by row, and then add these maximum values
C++ program: Given an integer matrix, please find the maximum value of each row row by row, and then add these maximum values

The matrix can be represented by a two-dimensional array

#include

using namespace std;

const x=7,y =5;//7 and 5 here are examples, you can change them yourself, be careful not to make mistakes when assigning values ??to the array

int main()

{

int a[x][y]={{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15},{16, 17,18,19,20},{21,22,23,24,25},{26,27,28,29,30},{31,32,33,34,35}};

int i,j,I,M=0;

for(i=0;i

{

for( j=1,I=a[i][0];j

{

if(I

}

cout<<"The maximum value in row i is:"<

M+= I;

}

cout<<"The sum of all the largest elements is:"<

return 0;

}