-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntro2D.java
More file actions
69 lines (63 loc) · 1.71 KB
/
Copy pathIntro2D.java
File metadata and controls
69 lines (63 loc) · 1.71 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.example.Intro2D;
public class Intro2D {
/*
A. 0
B. 1
C. Out of bound
D. 3
E. k
F. Out of bound
G. 105
H. o
I. 7, 6
*/
public void matrix(int n){
int a[][] = new int[n][n];
int num = 0;
for (int i = 0; i <= n - 1; i++){
for (int j = 0; j <= n -1; j++){
a[i][j] = num;
num++;
}
}
for (int i = 0; i <= n - 1; i++){
for (int j = 0; j <= n -1; j++){
System.out.print(a[i][j]);
}
System.out.println();
}
}
public void whatNum(int n[][]){
int column = n[0].length;
System.out.println(column);
int row = n.length;
System.out.println(row);
}
public void six(int n, int m, int k, int x, int y, int z){
int a[][] = new int[3][];
a[0] = new int[3];
a[1] = new int[2];
a[2] = new int[1];
a[0][0] = n;
a[0][1] = m;
a[0][2] = k;
a[1][0] = x;
a[1][1] = y;
a[2][0] = z;
System.out.print(a[0][0] + " ");
System.out.print(a[0][1] + " ");
System.out.print(a[0][2] + " ");
System.out.println();
System.out.print(a[1][0] + " ");
System.out.print(a[1][1] + " ");
System.out.println();
System.out.print(a[2][0] + " ");
}
public static void main(String[]args){
Intro2D runner = new Intro2D();
int a[][] = {{1, 2, 3, 4}, {4, 5, 6, 9}, {7, 8, 9, 10}, {7, 8, 9, 10}};
runner.matrix(6);
runner.whatNum(a);
runner.six(1, 2, 3, 4, 5, 6);
}
}