![[백준 / BOJ] 11021번 A+B - 7 (C++, Python)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbfDa2p%2FbtrL6RRlAKx%2FldmoJXtCnCugt77xHMH7yk%2Fimg.jpg)
[백준 / BOJ] 11021번 A+B - 7 (C++, Python)◎ 자료구조와 알고리즘/백준(BOJ) 문제풀이2021. 8. 23. 00:39
반응형
링크 : https://www.acmicpc.net/problem/11021
11021번: A+B - 7
각 테스트 케이스마다 "Case #x: "를 출력한 다음, A+B를 출력한다. 테스트 케이스 번호는 1부터 시작한다.
www.acmicpc.net
문제
![](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
문제 풀이
출력 양식만 잘 신경쓰면 되는 문제다!
코드 전문
C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
void init() { | |
std::ios_base::sync_with_stdio(false); | |
std::cin.tie(nullptr); | |
std::cout.tie(nullptr); | |
} | |
int main() { | |
int var, x, y; | |
std::cin >> var; | |
for (int i = 1; i <= var; ++i) { | |
std::cin >> x >> y; | |
std::cout << "Case #" << i << ": " << x + y << "\n"; | |
} | |
return 0; | |
} |
Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
input = sys.stdin.readline | |
if __name__ == "__main__": | |
for i in range(int(input())): | |
x, y = map(int, input().split()) | |
print(f"Case #{i+1}: {x + y}") |
소감
반응형
'◎ 자료구조와 알고리즘 > 백준(BOJ) 문제풀이' 카테고리의 다른 글
[백준 / BOJ] 2438번 별 찍기 - 1 (C++, Python) (0) | 2021.08.23 |
---|---|
[백준 / BOJ] 11022번 A+B - 8 (C++, Python) (0) | 2021.08.23 |
[백준 / BOJ] 2742번 기찍 N (C++, Python) (0) | 2021.08.23 |
[백준 / BOJ] 2741번 N 찍기 (C++, Python) (0) | 2021.08.23 |
[백준 / BOJ] 15552번 빠른 A+B (C++, Python) (0) | 2021.08.22 |
@Reo :: 코드 아카이브
자기계발 블로그