-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathnumericpattern121.java
More file actions
48 lines (42 loc) · 1002 Bytes
/
numericpattern121.java
File metadata and controls
48 lines (42 loc) · 1002 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
40
41
42
43
44
45
46
47
48
/**
*
* pattern to be printed
*
* 3
* 3 2
* 3 2 1
* 3 2 1 0
* 3 2 1
* 3 2
* 3
*
*
* numericpattern121
*/
class numericpattern121 {
public static void main(String[] args) {
int rows = 7;
numericPattern121(rows);
}
private static void numericPattern121(int n) {
n/=2;
for (int i = 0; i <= n; i++) {
for (int j = 1; j <=n-i; j++) {
System.out.print(" ");
}
for (int j = 0; j <= i; j++) {
System.out.print((n-j)+" ");
}
System.out.println();
}
for (int i = 0; i <= n; i++) {
for (int j = -1; j <i; j++) {
System.out.print(" ");
}
for (int j = 0; j < n-i; j++) {
System.out.print((n-j)+" ");
}
System.out.println();
}
}
}