package baekjoon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringTokenizer;
public class AplusB_4 {
public static void main(String[] args) throws IOException {
/*
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
입력
입력은 여러 개의 테스트 케이스로 이루어져 있다.
각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)
출력
각 테스트 케이스마다 A+B를 출력한다.
예제 입력 예제 출력
1 1 2
2 3 5
3 4 7
9 8 17
5 2 7
*/
// solution1();
// solution2();
solution3();
}
// public static void solution1() {
// Scanner in = new Scanner(System.in);
//
// while (in.hasNextInt()) {
// int A = in.nextInt();
// int B = in.nextInt();
// System.out.println(A + B);
// }
// in.close();
// }
// public static void solution2() throws IOException {
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// StringBuilder sb = new StringBuilder();
// StringTokenizer st;
// String str;
//
// while ((str=br.readLine()) != null) {
// st = new StringTokenizer(str, " ");
// int A = Integer.parseInt(st.nextToken());
// int B = Integer.parseInt(st.nextToken());
// sb.append(A+B).append("\n");
// }
// System.out.println(sb);
// }
public static void solution3() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
String str;
while ((str = br.readLine()) != null) {
int A = str.charAt(0) - 48;
int B = str.charAt(2) - 48;
sb.append(A+B).append("\n");
}
System.out.println(sb);
}
}
백준알고리즘 코드
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
// solution1();
// solution2();
solution3();
}
// public static void solution1() {
// Scanner in = new Scanner(System.in);
//
// while (in.hasNextInt()) {
// int A = in.nextInt();
// int B = in.nextInt();
// System.out.println(A + B);
// }
// in.close();
// }
// public static void solution2() throws IOException {
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// StringBuilder sb = new StringBuilder();
// StringTokenizer st;
// String str;
//
// while ((str=br.readLine()) != null) {
// st = new StringTokenizer(str, " ");
// int A = Integer.parseInt(st.nextToken());
// int B = Integer.parseInt(st.nextToken());
// sb.append(A+B).append("\n");
// }
// System.out.println(sb);
// }
public static void solution3() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
String str;
while ((str = br.readLine()) != null) {
int A = str.charAt(0) - 48;
int B = str.charAt(2) - 48;
sb.append(A+B).append("\n");
}
System.out.println(sb);
}
}