충분히 쌓여가는
백준[Java] 11022번 A+B-8 본문
https://www.acmicpc.net/problem/11022
문제풀이 1
import java.util.Scanner;
public class _11022_1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for (int i = 1; i <= T; i++) {
int A = sc.nextInt();
int B = sc.nextInt();
System.out.printf("Case #%d: %d + %d = %d%n", i, A, B, A+B);
}
sc.close();
}
}
문제풀이 2
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class _11022_2 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
for (int i = 1; i <= T; i++) {
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int A = Integer.parseInt(st.nextToken());
int B = Integer.parseInt(st.nextToken());
System.out.printf("Case #%d: %d + %d = %d%n", i, A, B, A+B);
}
br.close();
}
}
문제풀이 3
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class _11022_3 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
for (int i = 1; i <= T; i++) {
String[] str = br.readLine().split(" ");
int A = Integer.parseInt(str[0]);
int B = Integer.parseInt(str[1]);
System.out.printf("Case #%d: %d + %d = %d%n", i, A, B, A+B);
}
br.close();
}
}
문제풀이 4
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class _11022_4 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
StringBuilder sb = new StringBuilder();
StringTokenizer st;
for (int i = 1; i <= T; i++) {
st = new StringTokenizer(br.readLine(), " ");
int A = Integer.parseInt(st.nextToken());
int B = Integer.parseInt(st.nextToken());
sb.append("Case #" + i + ": ").append(A + " + " + B + " = " + (A+B)).append('\n');
}
br.close();
System.out.println(sb);
}
}
문제풀이 5
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
public class _11022_5 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int T = Integer.parseInt(br.readLine());
StringBuilder sb = new StringBuilder();
StringTokenizer st;
for (int i = 1; i <= T; i++) {
st = new StringTokenizer(br.readLine(), " ");
int A = Integer.parseInt(st.nextToken());
int B = Integer.parseInt(st.nextToken());
bw.write("Case #"+i+": ");
bw.write(A + " + " + B + " = ");
bw.write((A+B) + "\n");
}
br.close();
bw.flush();
bw.close();
}
}
문제풀이 6
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class _11022_6 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= T; i++) {
String str = br.readLine();
int A = str.charAt(0)-'0';
int B = str.charAt(2)-'0';
sb.append("Case #").append(i).append(": ").append(A)
.append(" + ").append(B).append(" = ").append(A+B).append('\n');
}
System.out.println(sb);
}
}
'IT > Java[백준]' 카테고리의 다른 글
백준[Java] 2439번 별 찍기 -2 (0) | 2023.02.21 |
---|---|
백준[Java] 2438번 별 찍기 -1 (0) | 2023.02.21 |
백준[Java] 11021번 A+B-7 (0) | 2023.02.20 |
백준[Java] 8393번 합 (*문제는 쉽지만 시간초과에 대한 문제! 중요!) (2) | 2023.02.17 |
백준[Java] 25304번 영수증 (0) | 2023.02.16 |