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

silver's avatar
May 10, 2025
[알고리즘문제풀기] a와 b 출력하기

문제

내가 작성한 정답

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