
|
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
|
package java1;
public class star2 {
public static void main(String[] args) {
// *********
// **** ****
// *** ***
// ** **
// * *
// ** **
// *** ***
// **** ****
// *********
// 9열 만들기 >
int cnt = 0;
for (int i=0; i<9; i++) {
for (int s=0; s<5-cnt; s++) {
System.out.print("*");
}
for (int x=0; x<4+cnt; x++) {
System.out.print(x<cnt*2-1?"&":"*");
}
System.out.println();
cnt = i<4? cnt+1 : cnt-1;
}
}
}
|
cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | package day_06; public class Day05homework { public static void main(String[] args) { // 강사님.ver // 공백 마름모 모양으로 별찍기 // for문을 9회전 하면서 5, 4, 3, 2, 1, 2, 3, 4, 5 출력되도록 한다. int cnt= 5; for(int i=0; i<9; i++){ for(int j=0; j<9; j++){ System.out.print(j<cnt || j>=9-cnt?"*":" "); } System.out.println(); cnt= i<4? cnt-1: cnt+1; } } } | cs |