0%

[백준/15552] 빠른 A+B

Baekjoon Online Judge - 15552

Review

  • 입출력 연습하는 문제.
  • BufferedReader를 통해서 입력을 받으면 된다.
  • 출력은 StringBuilder와 BufferedWriter를 각각 사용해서 풀었다.

Code (JAVA)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.io.*;

public class Main {
public static void main(String args[]) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();

int n = Integer.parseInt(bf.readLine());
int res = 0;

for(int i = 0; i < n; i++) {
String[] line = bf.readLine().split(" ");
res = Integer.parseInt(line[0]) + Integer.parseInt(line[1]);
sb.append(res + "\n");
}

System.out.println(sb);
}
}

Code (JAVA)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import java.io.*;

public class Main {
public static void main(String args[]) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

int n = Integer.parseInt(bf.readLine());
String res;

for(int i = 0; i < n; i++) {
String[] line = bf.readLine().split(" ");
res = (Integer.parseInt(line[0]) + Integer.parseInt(line[1])) + "\n";
bw.write(res);
}
bw.flush();
}
}