-
Notifications
You must be signed in to change notification settings - Fork 331
/
Copy pathRow_with_max_1s.java
46 lines (36 loc) · 901 Bytes
/
Row_with_max_1s.java
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
39
40
41
42
43
44
45
46
import java.util.Scanner;
public class Row_with_max_1s {
public static void maxs (int a[][])
{
int c=0;
for (int j=0;j<a[0].length;j++)
{
for (int i=0;i<a.length;i++)
{
if (a[i][j]==1)
{
System.out.println(i);
++c;
break;
}
}if (c==1) break;
}
}
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
int a[][]= new int [4][4];
for (int i =0;i<4;i++)
{
for (int j=0;j<4;j++)
a[i][j]= sc.nextInt();
}
for (int i =0;i<4;i++)
{
for (int j=0;j<4;j++)
System.out.print(a[i][j]+" ");
System.out.println();
}
maxs(a);
sc.close();
}
}