-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPattern26.java
More file actions
34 lines (34 loc) · 798 Bytes
/
Pattern26.java
File metadata and controls
34 lines (34 loc) · 798 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
public class Pattern26 {
public static void main(String[] args) {
int n=4;
for(int i=1; i<=n*2-1; i++){
int x = i>n?n*2-i:i;
for(int j=1; j<=x; j++){
if((i+j)%2==0){
System.out.print("* ");
}else{
System.out.print(" ");
}
}
for(int v=n; v>x; v--){
System.out.print(" ");
}
for(int l=x; l<n-1; l++){
System.out.print(" ");
}
for(int m=x; m>0; m--){
int h = m==n ? m-1:m;
if((h+x)%2==0){
System.out.print("* ");
}else{
if(m==n){
continue;
}else{
System.out.print(" ");
}
}
}
System.out.println();
}
}
}