-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStar7.java
More file actions
50 lines (38 loc) Β· 919 Bytes
/
Star7.java
File metadata and controls
50 lines (38 loc) Β· 919 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package basic.star;
import java.util.Scanner;
/*
*
***
*****
*******
*****
***
*
*/
public class Star7 implements StarInterface{
@Override
public void StarPrint() {
Scanner scan = new Scanner(System.in);
int H;
int re =0;
do{
if(re==0) System.out.println("νμλ₯Ό μ
λ ₯ν΄μ£Όμμμ.");
else System.out.println("μ§μλ₯Ό μ
λ ₯νμ
¨μ΅λλ€.");
H = scan.nextInt();
re++;
}while(H%2==0);
int HMid = H/2;
int W = H;
int WMid = W/2;
int star = 0;
for(int i = 0 ; i<H;i++){
for(int j = 0; j<W;j++){
if(WMid-star<=j&&WMid+star>=j) System.out.print("*");
else System.out.print(" ");
}
if(i<HMid) star++;
else star--;
System.out.println();
}
}
}