-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwoDArrayMatrix.java
54 lines (43 loc) · 999 Bytes
/
twoDArrayMatrix.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
47
48
49
50
51
52
53
54
import java.util.*;
class twoDArrayMatrix
{
public static void main(String[]args)
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the limit of rows and columns of matrix");
int rows=in.nextInt();
int colm=in.nextInt();
System.out.println("Enter the numbers into Matrix");
int numbers[][]=new int[rows][colm]; //array declaration
//Input
for(int i=0;i<rows;i++)
{
for(int j=0;j<colm;j++)
{
numbers[i][j]=in.nextInt();
}
}
//Output
for(int i=0;i<rows;i++)
{
for(int j=0;j<colm;j++)
{
System.out.print(numbers[i][j] +" ");
}
System.out.println();
}
System.out.println();
System.out.println("Enter the number which you want to find..");
int x = in.nextInt();
for(int i=0;i<rows;i++)
{
for(int j=0;j<colm;j++)
{
if(numbers[i][j]== x)
{
System.out.println("Number is found in array at " +"(" +i +"," +j +")" );
}
}
}
}
}