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

Hollow Diamond in java #457

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Beginner Level/HollowDiamond.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
public class hollow {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();


for(int i=1;i<=n;i++){

for(int j=n-i;j>=0;j--){
System.out.print("*");
}

for(int k=2*(i-1);k>0;k--){
System.out.print(" ");
}
for(int l=n-i;l>=0;l--){
System.out.print("*");
}
System.out.println();
}

for(int i=0;i<n;i++){
for(int j=0;j<=i;j++){
System.out.print("*");
}
for(int k=2*(n-i-1);k>0;k--){
System.out.print(" ");
}
for(int m=0;m<=i;m++){
System.out.print("*");
}
System.out.println();
}
}

}