-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaximumrow.txt
More file actions
30 lines (28 loc) · 794 Bytes
/
Copy pathMaximumrow.txt
File metadata and controls
30 lines (28 loc) · 794 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
import java.util.*;
public class MaximumRow {
public static void main(String args[]){
int matrix[][]={{1,2,3},{4,5,6},{6,7,8}};
int maxsum = Integer.MIN_VALUE;
int maxrow=-1;
for(int i=0;i<matrix.length;i++){
int sum=0;
for(int j=0;j<matrix[i].length;j++){
sum=sum+matrix[i][j];
}
if(sum>maxsum){
maxsum=sum;
maxrow=i;
}
}
// Discard option
for(int i=0;i<matrix.length;i++){
if(maxrow==i){
continue;
}
for(int j=0;j<matrix[i].length;j++){
System.out.println(matrix[i][j]+ " ");
}
System.out.println();
}
}
}