Skip to content
This repository was archived by the owner on Nov 3, 2024. It is now read-only.

Commit e716c81

Browse files
Hollow Diamond in java
Pattern for Hollow Diamond in java
1 parent 5aefa58 commit e716c81

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Beginner Level/HollowDiamond.java

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
public class hollow {
2+
public static void main(String[] args){
3+
Scanner sc=new Scanner(System.in);
4+
int n=sc.nextInt();
5+
6+
7+
for(int i=1;i<=n;i++){
8+
9+
for(int j=n-i;j>=0;j--){
10+
System.out.print("*");
11+
}
12+
13+
for(int k=2*(i-1);k>0;k--){
14+
System.out.print(" ");
15+
}
16+
for(int l=n-i;l>=0;l--){
17+
System.out.print("*");
18+
}
19+
System.out.println();
20+
}
21+
22+
for(int i=0;i<n;i++){
23+
for(int j=0;j<=i;j++){
24+
System.out.print("*");
25+
}
26+
for(int k=2*(n-i-1);k>0;k--){
27+
System.out.print(" ");
28+
}
29+
for(int m=0;m<=i;m++){
30+
System.out.print("*");
31+
}
32+
System.out.println();
33+
}
34+
}
35+
36+
}

0 commit comments

Comments
 (0)