문제 url : 삼각형 출력하기 5 (codeup.kr) 어떤 수 n을 입력받으면 다음과 같은 삼각형을 출력한다. 여기서 입력되는 n은 반드시 홀수이다. 2.
입력 3부터 99 까지의 홀수 중 하나가 입력된다. 3. 출력 * *** ***** 4.
내 풀이 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a=(n/2)+1; for(int i=1; i<=a;i++) { for(int j=a-1;j>=i;j--) { System.out.print(" "); } for(int k=1;k<=2*i-1;k++) { System.out.print("*"); } System.out.println(""); } sc.close(); }...
#
codeup
#
java
#
자바
#
자바연습문제
#
중첩반복문
#
코드업
원문 링크 : [CodeUp Java] 1358 : 삼각형 출력하기 5