-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlargestRowSum.cpp
More file actions
38 lines (33 loc) · 779 Bytes
/
largestRowSum.cpp
File metadata and controls
38 lines (33 loc) · 779 Bytes
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
36
37
38
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
cout << "enter the nmber of rows " ;
int row;
cin >> row;
int col;
cout << "Enter the number of columns ";
cin >> col;
int arr[row][col];
cout << "Enter the elements ";
for(int i = 0; i<row; i++){
for(int j = 0; j<col; j++){
cin >> arr[i][j];
}
}
int max = INT32_MIN;
int ans = 0;
for(int i = 0; i<row; i++){
int sum = 0;
for(int j = 0; j<col; j++){
sum += arr[i][j];
}
if(sum > max){
max = sum;
ans = i+1;
}
}
cout << "Maximum Sum of row is " << max << endl;
cout << "Number of the row is " << ans << endl;
return 0;
}