-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwodarrays.java
More file actions
39 lines (29 loc) · 905 Bytes
/
Copy pathtwodarrays.java
File metadata and controls
39 lines (29 loc) · 905 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
39
import java.util.*;
public class twodarrays {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int rows = scn.nextInt();
int cols = scn.nextInt();
int arr[][] = new int[rows][cols];
for(int i = 0;i<rows;i++){
for(int j = 0;j<cols;j++){
arr[i][j] = scn.nextInt();
}
}
// //output
// for(int i = 0;i<rows;i++){
// for(int j = 0;j<cols;j++){
// System.out.print(arr[i][j] + " ");
// }
// System.out.println();
// }
int x = scn.nextInt();
for(int i = 0;i<rows;i++){
for(int j = 0;j<cols;j++){
if(arr[i][j] == x){
System.out.print("x found at indices (" + i + "," + j + ")");
}
}
}
}
}