[Java | 백준 2444번] 별찍기 - 7
· 테크· Java
Java
백준 2444번 www.acmicpc.net/problem/2444
풀이
중첩 for문을 이용해서 풀이했다. 별찍기 문제 원리를 파악해둘것!
|
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
|
import java.util.*;
public class for_2444 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
for (int i=1; i<=n; i++) {
for (int j=0; j<n-i; j++) {
System.out.print(" ");
}
for (int j=0; j<2*i-1; j++) {
System.out.print("*");
}
System.out.print("\n");
}
for (int i=1; i<n; i++) {
for (int j=0; j<i; j++) {
System.out.print(" ");
}
for (int j=0; j<2*n-2*i-1; j++) {
System.out.print("*");
}
System.out.print("\n");
}
}
}
|
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