-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSymmetricalPyramid.java
More file actions
29 lines (27 loc) · 903 Bytes
/
SymmetricalPyramid.java
File metadata and controls
29 lines (27 loc) · 903 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
import java.util.Scanner;
class SymmetricalPyramid{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i = 0; i < n; i++){
for(int j = n; j > i; j--){
System.out.print(" ");
}
for(int j = 1; j < i; j++){
System.out.print(i-j);
}
for(int j = 2; j < i; j++){
System.out.print(j);
}
System.out.println("");}
for(int i = 0; i < n; i++){
for(int j = 0; j < i; j++){
System.out.print(" ");
}
for(int j = 8; j > i; j--){
System.out.print(j - i);
}
for(int j = 8-1; j > i; j--){
System.out.print(9 - j);}
System.out.println(""); }}
}