inblog logo
|
silver
    알고리즘문제풀기

    [알고리즘문제풀기] 직각삼각형 출력하기

    silver's avatar
    silver
    Nov 29, 2025
    [알고리즘문제풀기] 직각삼각형 출력하기
    Contents
    문제내가 작성한 정답다른 사람들의 정답

    문제

    school.programmers.co.kr
    https://school.programmers.co.kr/learn/courses/30/lessons/120823

    내가 작성한 정답

    import java.util.Scanner; class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i=1; i<=n; i++){ for(int j=1; j<=i; j++){ System.out.printf("*"); } System.out.printf("\n"); } } }

    다른 사람들의 정답

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i=1; i<=n; i++){ System.out.println("*".repeat(i)); } } }
    Share article

    silver

    RSS·Powered by Inblog