- Notifications
You must be signed in to change notification settings - Fork 366
/
Copy pathQuestion15.java
31 lines (31 loc) · 1.11 KB
/
Question15.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
importjava.io.IOException;
importjava.io.*;
publicclassCodechef3 {
publicstaticvoidmain(String[] args) throwsIOException{
BufferedReaderbr = newBufferedReader(newInputStreamReader(System.in));
intn = Integer.parseInt(br.readLine());
for (introw = 0; row < n; row++) {
for (intspaces = n; spaces > row; spaces--) {
System.out.print(" ");
}
if(row%2!=0){
for (inti = 0; i <= row; i++) {
if (i%2!=0 || i != 1) {
if(i == 0 || i == row){
System.out.print("* ");
}
else{
System.out.print(" ");
}
}
}
}
else{
for (inti = 0; i <= row; i++) {
System.out.print("* ");
}
}
System.out.println();
}
}
}