-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPattern20.java
More file actions
38 lines (37 loc) · 1.1 KB
/
Pattern20.java
File metadata and controls
38 lines (37 loc) · 1.1 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
public class Pattern20 {
public Pattern20(int n){
for(int row=n;row>1;row--){
for(int col = row;col>=1;col--){
System.out.print("* ");
}
for (int col = 2*n-row-1; col >= row ; col--) {
System.out.print(" ");
}
for (int col = row; col >0; col--) {
System.out.print("* ");
}
if(row>2){
System.out.println();
}else{
continue;
}
}
for (int row = 0; row <= n; row++) {
for (int col = 1; col <= row; col++) {
System.out.print("* ");
}
for (int col = row ; col <= n-1; col++) {
System.out.print(" ");
}
int c =row>n?2*n-row:row;
for (int col = 1; col <= c; col++) {
System.out.print("* ");
}
System.out.println();
}
}
public static void main(String[] args) {
Pattern20 foo = new Pattern20(5);
System.out.println(foo);
}
}