Java 별찍기 문제
· 테크· Java
Java
| 문제1 | 문제2 | 문제3 | 문제4 | 문제5 | 문제6 | 문제7 |
| * ** *** **** ***** |
***** **** *** ** * |
***** **** *** ** * |
* *** ***** |
***** *** * |
* *** ***** *** * |
*********9 ********8 *******7 ******6 *****5 ****4 ***3 **2 *1 |
|
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
//문제 1.
System.out.println("\n== 문제 1 ==");
for(int a=1; a<6; a++) {
for (int b=0; b<a; b++) {
System.out.print("*");
}
System.out.println("");
}
//문제 2.
System.out.println("\n== 문제 2 ==");
for(int a=1; a<6; a++) {
for(int b=5; b>a; b--) {
System.out.print(" ");
}
for (int c=0; c<a; c++) {
System.out.print("*");
}
System.out.println("");
}
//문제 3.
System.out.println("\n== 문제 3 ==");
for(int a=6; a>1; a--) {
for (int b=1; b<a; b++) {
System.out.printf("%s","*");
}
System.out.println("");
}
//문제 4.
System.out.println("\n== 문제 4 ==");
for(int a=1; a<6; a++) {
for(int b=3; b>a; b--) {
System.out.print(" ");
}
if(a%2==0) continue;
for (int c=0; c<a; c++) {
System.out.print("*");
}
System.out.println("");
}
//문제 5.
System.out.println("\n==문제 5 ==");
for(int a=0; a<5; a++) {
for(int b=1; b<=a; b++) {
System.out.print(" ");
}
for (int c=5; c>=a*2+1; c--) {
System.out.print("*");
}
System.out.println("");
}
//문제 6.
System.out.println("\n== 문제 6 ==");
for(int a=1; a<4; a++) {
for(int b=3; b>a; b--) {
System.out.print(" ");
}
for (int c=0; c<a*2-1; c++) {
System.out.print("*");
}
System.out.println("");
}
for(int a=0; a<3; a++) {
for(int b=1; b<a+2; b++) {
System.out.print(" ");
}
for (int c=4; c>a*2+1; c--) {
System.out.print("*");
}
System.out.println("");
}
//문제7.
System.out.println("\n== 문제 7 ==");
int a1,b;
for(a1=9; a1>0; a1--) {
for (b=0; b<a1; b++) {
System.out.print("*");
}
System.out.println(a1);
}
|
cs |
Comments
No comments yet. Be the first!
319 posts in 테크
- 368Supabase 프로젝트 복사하기 (Restore to a New Project)NEW
- 341Migrating from Permanent Access Tokens to Token Exchange — Why Order Matters
- 326Startup & Product Glossary: Terms Every Solo Founder Should Know
- 325Context Management — How I Do It Now
- 324Claude Code Routines vs Cowork Schedule — What's the Difference?
1–5 / 319