Algorithm
Staricase
후니우니
2020. 10. 10. 16:57
반응형
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
// Complete the staircase function below.
static void staircase(int n) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (j >= n-i-1)
System.out.printf("#");
else
System.out.printf(" ");
}
System.out.println("");
}
}
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int n = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
staircase(n);
scanner.close();
}
}
단순한 별찍기문제
이차원 배열을 생각하고 문제를 풀면 된다
문제출처 : www.hackerrank.com
반응형