-
Notifications
You must be signed in to change notification settings - Fork 0
/
08Patterns.java
64 lines (55 loc) · 2.36 KB
/
08Patterns.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
55
56
57
58
59
60
61
62
63
64
class Patterns {
final static int NO_OF_ROWS = 5;
public static void main(String args[]) {
for (int i = 0; i < NO_OF_ROWS; i++) {
for (int j = 0; j <= i; j++) {
System.out.print("* ");
}
System.out.println();
}
System.out.println();
// ________________________________________________________________________________________________________________________________________________________________
for (int i = NO_OF_ROWS; i > 0; i--) {
for (int j = 0; j < i; j++) {
System.out.print("* ");
}
System.out.println();
}
System.out.println();
// ________________________________________________________________________________________________________________________________________________________________
for (int i = 0; i < NO_OF_ROWS; i++) {
for (int k = NO_OF_ROWS - 1; k > i; k--) {
System.out.print(" ");
}
for (int j = 0; j <= i; j++) {
System.out.print("* ");
}
System.out.println();
}
System.out.println();
// ________________________________________________________________________________________________________________________________________________________________
for (int i = 0; i < NO_OF_ROWS; i++) {
for (int k = NO_OF_ROWS - 1; k > i; k--) {
System.out.print(" ");
}
for (int j = 0; j <= i; j++) {
System.out.print("* ");
}
System.out.println();
}
System.out.println();
// ________________________________________________________________________________________________________________________________________________________________
for (int i = 1; i <= NO_OF_ROWS; i++) {
int diff = NO_OF_ROWS - 1;
int offset = i;
for (int j = 0; j < i; j++) {
System.out.print(offset + " ");
offset += diff;
diff--;
}
System.out.println();
}
System.out.println();
// ________________________________________________________________________________________________________________________________________________________________
}
}