0

How to compare sum of each rows of matrix?

I can find sum of them , but i couldn't compare them HELP #include <iostream> using namespace std; /* * * This function finds the array * in which total number of positive elements is bigger * * * */ int findBig(int arr[100][100], int n, int p) { int i, j, sum = 0; for (i = 0; i < n; ++i) { for (j = 0; j < p; ++j) { if (arr[i][j] > 0) { sum = sum + arr[i][j]; } } cout << sum << endl; sum = 0; } return sum; } int main() { int n; int p; cin >> n >> p; int ar1[100][100]; for (int i = 0; i < n; i++) { for (int j = 0; j < p; j++) { cin >> ar1[i][j]; } } findBig(ar1, n, p); }

10th Oct 2020, 2:56 PM
Azat Malgazhdar
Azat Malgazhdar - avatar
1 Réponse
0
Do you want find max of row sums..? If yes, take another variable maxr=0; And compare like if(sum>maxr) maxr=sum; Next set sum=0; return maxr;
10th Oct 2020, 3:11 PM
Jayakrishna 🇮🇳