BAEKJOON

JAVA -백준(BAEKJOON)(BAEKJOON) 2441번 문제 답

dev-include 2017. 7. 26. 11:56

첫째 줄에는  N둘째 줄에는  N-1, ..., N번째 줄에는  1개를 찍는 문제

하지만오른쪽을 기준으로 정렬한  (예제 참고) 출력하시오.




import java.util.Scanner;


public class Main {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

for (int a = 0; a < n; a++) {

for(int c=0; c<a; c++)

{

System.out.print(" ");

}

for(int b=0; b<n-a; b++){

System.out.print("*");

}

System.out.println();

}

sc.close();

}

}