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

    [알고리즘문제풀기] a와 b 출력하기

    silver's avatar
    silver
    May 10, 2025
    [알고리즘문제풀기] a와 b 출력하기
    Contents
    문제내가 작성한 정답다른 사람들의 정답

    문제

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

    내가 작성한 정답

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println("a = " + a); System.out.println("b = " + b); 또는 System.out.println("a = " + a + "\n" + "b = " + b); } }

    다른 사람들의 정답

    close를 해서 사용했던 시스템 자원(입력 스트림)을 운영체제에 반환하여 자원을 효율적으로 관리하고 메모리 누수를 방지하기 한다.
    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println("a = " + a); System.out.println("b = " + b); sc.close(); } }
    Share article

    silver

    RSS·Powered by Inblog