728x90
https://www.acmicpc.net/problem/15552
# Scanner 사용 - 시간초과
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i=0; i<t; i++) {
System.out.println(sc.nextInt() + sc.nextInt());
}
}
}
# BufferedReader, BufferedWriter 사용
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st;
int t = Integer.parseInt(br.readLine());
for (int i=0; i<t; i++) {
st = new StringTokenizer(br.readLine());
bw.write(Integer.parseInt(st.nextToken())+Integer.parseInt(st.nextToken())+"\n");
}
br.close();
bw.close();
} catch (IOException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}
반응형
'전.java' 카테고리의 다른 글
[Java] 백준 10807 개수 세기 (1) | 2023.01.16 |
---|---|
[Java] 백준 14681 사분면 고르기 (0) | 2023.01.16 |
[Java] StringTokenizer (0) | 2023.01.16 |
[Java] 입출력 (0) | 2023.01.16 |
스레드 (0) | 2021.02.14 |