-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStarEx01.java
More file actions
54 lines (44 loc) · 995 Bytes
/
Copy pathStarEx01.java
File metadata and controls
54 lines (44 loc) · 995 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
51
52
53
54
package java2;
/**
*
* @author 별그리기
* 밖에 있는 for문은 행(가로)의 개수
* 안에 있는 for문은 열(세로)의 개수
*/
public class StarEx01 {
public static void main(String[] args) {
System.out.println(" *"); //공백 3, 별 1
System.out.println(" ***"); //공백 1, 별 3
System.out.println("*****"); //공백 0, 별 5
System.out.println();
for (int i = 0; i<4; i++) {
if (i==3) {
System.out.print("*");
}else {
System.out.print(" ");
}
}
System.out.println();
System.out.println("======별그리기=====");
for (int i = 0; i<5; i++) {
if(i==3) {
System.out.print("*");
break; //반복문을 빠져나가!!
}
System.out.print(" ");
}
System.out.println();
for (int i=0; i <5; i++) {
if(i==0) {
System.out.print(" ");
}else {
if(i==4) break;
System.out.print("*");
}
}
System.out.println();
for(int i=0; i<5; i++) {
System.out.print("*");
}
}
}