Coding Test/백준
[백준/자바] 11382 - 꼬마 정민
yurison
2023. 5. 5. 16:08
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long a = sc.nextInt();
long b = sc.nextInt();
long c = sc.nextInt();
System.out.println(a + b + c);
sc.close();
}
}
Scanner를 이용하니 런타임 에러가 떴다.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
long a = Long.parseLong(st.nextToken());
long b = Long.parseLong(st.nextToken());
long c = Long.parseLong(st.nextToken());
System.out.println(a + b + c);
br.close();
}
}
BufferedReader, StringTokenizer로 입력값을 받으니 성공