-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTwoDimensional.java
34 lines (34 loc) · 960 Bytes
/
TwoDimensional.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.*;
public class TwoDimensional{
public static boolean search(int matrix[][],int key){
int n=3,m=3;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(matrix[i][j]==key){
System.out.println(" Found at cell: ( " +i+ "," +j+ ")");
return true;
}
}
}
System.out.println("Not found");
return false;
}
public static void main(String args[]){
int matrix[][]=new int[3][3];
int n=3,m=3;
Scanner sc=new Scanner(System.in);
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
matrix[i][j]=sc.nextInt();
}
}
//ffor output
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
System.out.print(+matrix[i][j]+" ");
}
System.out.println();
}
search(matrix,5);
}
}