CS/알고리즘 풀이
[알고리즘_입출력] 백준 2446번 별찍기
Selina Park
2019. 8. 6. 00:48
// N=5
// *********
// *******
// *****
// ***
// *
// ***
// *****
// *******
// *********
package input_output;
import java.util.Scanner;
public class backjoon_2446 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
for(int i=1-N; i<N; i++){
int a = (N-1) - Math.abs(i);
int b = (2*N-1) - 2*a;
for(int j=0; j<a; j++){
System.out.print(" ");
}
for(int j=0; j<b; j++){
System.out.print("*");
}
System.out.println();
}
}
}
https://www.acmicpc.net/problem/2446
2446번: 별 찍기 - 9
첫째 줄부터 2×N-1번째 줄까지 차례대로 별을 출력한다.
www.acmicpc.net