Algorithm/BOJ

[백준/C99/Python] 9295 주사위

Logistic 2024. 8. 6. 00:09

문제

- https://www.acmicpc.net/problem/9295


풀이

주사위를 두 번 던져 나온 두 수를 a와 b로 가정한다면 Case X: 를 출력후 뒤에 두 수의 합 a+b의 값을 출력해준다.

여기서 Case 번호는 1부터 시작한다는것을 명심하자.

 


코드

< C99 >

#include <stdio.h>

int main(void) {
    int t_case;
    int a, b;
    scanf("%d", &t_case);
    for (int i = 1; i <= t_case; i++) {
        scanf("%d %d", &a, &b);
        printf("Case %d: %d\n", i, a + b);
    }
}

 

< Python 3 >

t_case = int(input())
for i in range(1,t_case+1):
    a,b = map(int,input().split())
    print(f"Case {i}: {a+b}")