-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is my first try for contributing in opensource
- Loading branch information
1 parent
9ba1c5e
commit 85d5341
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import java.util.*; | ||
public class star { | ||
public static void main(String[] args) { | ||
Scanner scn = new Scanner (System.in); | ||
int N = scn.nextInt(); | ||
|
||
//upperstar | ||
for(int i = 1 ; i<=N ; i++){ | ||
for(int j = 1; j<=2*N-i ; j++){ | ||
System.out.print(" "); | ||
} | ||
for(int k = 0 ; k<2*i-1 ; k++){ | ||
System.out.print("*"); | ||
} | ||
System.out.println(); | ||
} | ||
|
||
//upper2 | ||
for(int i = 0 ; i < N ; i++){ | ||
for(int a = 0 ; a<i ; a++){ | ||
System.out.print(" "); | ||
} | ||
for(int b = 1 ; b<4*N-2*i; b++){ | ||
System.out.print("*"); | ||
} | ||
System.out.println(); | ||
} | ||
|
||
//upper3 | ||
for(int i = 1 ; i <= N ; i++){ | ||
for(int a = 0 ; a<N-i ; a++){ | ||
System.out.print(" "); | ||
} | ||
for(int b = 1 ; b<2*N+2*i; b++){ | ||
System.out.print("*"); | ||
} | ||
System.out.println(); | ||
} | ||
|
||
//bottom | ||
for(int i = 0 ; i< N ; i++){ | ||
for(int j = 1 ; j<=N+i ; j++){ | ||
System.out.print(" "); | ||
} | ||
for(int k = 1; k<2*(N-i); k++){ | ||
System.out.print("*"); | ||
} | ||
System.out.println(); | ||
} | ||
scn.close(); | ||
} | ||
|
||
} |