충분히 쌓여가는
백준[Java] 10952번 A+B-5 [charAt 사용] 본문
https://www.acmicpc.net/problem/10952
문제풀이 1
import java.util.Scanner;
public class _10952_1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (1>0) {
int A = sc.nextInt();
int B = sc.nextInt();
if (A==0 && B==0)
break;
else
System.out.println(A+B);
}
sc.close();
}
}
문제풀이 2
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class _10952_2 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
while (1>0) {
st = new StringTokenizer(br.readLine(), " ");
int A = Integer.parseInt(st.nextToken());
int B = Integer.parseInt(st.nextToken());
if (A==0 && B==0)
break;
else
System.out.println(A+B);
}
br.close();
}
}
문제풀이 3
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class _10952_3 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
StringBuilder sb = new StringBuilder();
while (1>0) {
st = new StringTokenizer(br.readLine(), " ");
int A = Integer.parseInt(st.nextToken());
int B = Integer.parseInt(st.nextToken());
if (A==0 && B==0)
break;
else
sb.append(A+B).append('\n');
}
br.close();
System.out.println(sb);
}
}
문제풀이 4
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class _10952_4 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
while (1>0) {
String str = br.readLine();
int A = str.charAt(0)-'0';
// int A = str.charAt(0) - 48;
// int A = str.charAt(0) - 48;
int B = str.charAt(2)-'0';
// int B = str.charAt(2) - 48;
if (A==0 && B==0)
break;
else
sb.append(A+B).append('\n');
}
br.close();
System.out.println(sb);
}
}
'IT > Java[백준]' 카테고리의 다른 글
백준[Java] 10807번 개수 세기 (0) | 2023.02.25 |
---|---|
백준[Java] 10951번 A+B-4 (hasNextInt 사용 [중요!]) (1) | 2023.02.23 |
백준[Java] 2439번 별 찍기 -2 (0) | 2023.02.21 |
백준[Java] 2438번 별 찍기 -1 (0) | 2023.02.21 |
백준[Java] 11022번 A+B-8 (0) | 2023.02.20 |