-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmxn.java
34 lines (34 loc) · 916 Bytes
/
mxn.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
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;
public class mxn{
public static void main(String args[]){
int columnTobeMarked = 0;
int rowTobeMarked = 0;
HashMap<Integer,Integer> rowCOlumn = new HashMap<Integer,Integer>();
int[][] matrix = new int[][]{{1,2,3},{2,0,4},{4,3,2}};
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
if(matrix[i][j]==0){
rowCOlumn.put(i, j);
}
}
}
Iterator it = rowCOlumn.entrySet().iterator();
while(it.hasNext()){
Map.Entry pair = (Map.Entry)it.next();
for(int k=0;k<3;k++){
matrix[(int)pair.getKey()][k]=0;
}
for(int l=0;l<3;l++){
matrix[l][(int)pair.getValue()]=0;
}
}
for(int sd=0;sd<3;sd++){
for(int we=0;we<3;we++){
System.out.println(""+matrix[sd][we]);
}
}
}
}