반응형
250x250
Notice
Recent Posts
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
관리 메뉴

코딩연습장

백준 - A+B - 8 11022번[Java, C, Python] 본문

백준

백준 - A+B - 8 11022번[Java, C, Python]

감귤짱 2023. 7. 31. 09:00
728x90
반응형

A+B - 8 11022번

 

[ 문제 ]

두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.

 

입력 ]

첫째 줄에 테스트 케이스의 개수 T가 주어진다.

각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)

 

출력 ]

각 테스트 케이스마다 "Case #x: A + B = C" 형식으로 출력한다. x는 테스트 케이스 번호이고 1부터 시작하며, C는 A+B이다.

 

[ 입출력 예 ]

예제 입력 1

5
1 1
2 3
3 4
9 8
5 2

예제 출력 1

Case #1: 1 + 1 = 2
Case #2: 2 + 3 = 5
Case #3: 3 + 4 = 7
Case #4: 9 + 8 = 17
Case #5: 5 + 2 = 7

 

[ 출처 ]

  • 문제를 만든 사람: baekjoon
  • 빠진 조건을 찾은 사람: djm03178

[ 알고리즘 분류 ]

  • 수학
  • 구현
  • 사칙연산

 

728x90
반응형

 

Java

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		for(int i=1;i<=num;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println("Case #" + i +  ": "  + a + " + " + b + " = " + (a+b));
		}
	}
}

 

C

#include <stdio.h>
main()
{
    int a, b, num;
    scanf("%d", &num);
    for (int i=1;i<=num;i++)
    {
        scanf("%d %d", &a, &b);
        printf("Case #%d: %d + %d = %d\n", i, a, b, (a+b));
    }
}

 

Python

num = int(input())
for i in range(1, num+1):
    a, b = map(int, input().split())
    print('Case #' + str(i) + ': ' + str(a) + ' + ' + str(b) + ' = ' + str(a+b))

 

 

 

https://www.acmicpc.net/problem/11022

 

11022번: A+B - 8

각 테스트 케이스마다 "Case #x: A + B = C" 형식으로 출력한다. x는 테스트 케이스 번호이고 1부터 시작하며, C는 A+B이다.

www.acmicpc.net

 

728x90
반응형