[2739번] 1. 구구단
C++
#include<iostream>
int main(int argc, char* argv[])
{
int N;
std::cin >> N;
for (int i = 1; i < 10; ++i) {
std::cout << N << " * " << i << " = " << N * i << std::endl;
}
return 0;
}
Python
N = int(input())
for i in range(1, 10):
print("{} * {} = {}".format(N, i, N*i))
[10950번] 2. A+B - 3
C++
#include <iostream>
int main()
{
int iter, A, B;
std::cin >> iter;
for (int i = 1; i <= iter; ++i) {
std::cin >> A >> B;
std::cout << A + B << std::endl;
}
return 0;
}
Python
iter = int(input())
for i in range(iter):
A, B = list(map(int, input().split()))
print(A+B)
[8393번] 3. 합
C++
#include <iostream>
int main()
{
int n;
int answer = 0;
std::cin >> n;
for (int i = 1; i <= n; ++i) {
answer += i;
}
std::cout << answer;
return 0;
}
Python
n = int(input())
answer = 0
for i in range(1, n+1):
answer += i
print(answer)
[15552번] 4. 빠른 A+B
C++
#include <iostream>
int main()
{
std::ios::sync_with_stdio(false); std::cin.tie(NULL);
int n;
int A, B;
std::cin >> n;
for (int i = 1; i <= n; ++i) {
std::cin >> A >> B;
std::cout << A + B << "\n";
}
return 0;
}
Python
import sys
input = sys.stdin.readline
n = int(input())
for i in range(1, n+1):
A, B = list(map(int, input().split()))
print(A+B)
[2741번] 5. N 찍기
C++
#include <iostream>
int main()
{
std::ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
int N;
std::cin >> N;
for (int i = 1; i <= N; ++i) {
std::cout << i << "\n";
}
return 0;
}
Python
import sys
input = sys.stdin.readline
N = int(input())
for i in range(1, N+1):
print(i)
[2742번] 6. 기찍 N
C++
#include <iostream>
int main()
{
std::ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
int N;
std::cin >> N;
for (int i = N; i >= 1; --i) {
std::cout << i << "\n";
}
return 0;
}
Python
import sys
input = sys.stdin.readline
N = int(input())
for i in range(N, 0, -1):
print(i)
[11021번] 7. A+B - 7
C++
#include <iostream>
int main()
{
std::ios::sync_with_stdio(false); std::cin.tie(NULL);
int n;
int A, B;
std::cin >> n;
for (int i = 1; i <= n; ++i) {
std::cin >> A >> B;
std::cout << "Case #" << i << ": " << A+B << "\n";
}
return 0;
}
Python
import sys
input = sys.stdin.readline
n = int(input())
for i in range(1, n+1):
A, B = list(map(int, input().split()))
print("Case #{}: {}".format(i, A+B))
[11022번] 8. A+B - 8
C++
#include <iostream>
int main()
{
std::ios::sync_with_stdio(false); std::cin.tie(NULL);
int n;
int A, B;
std::cin >> n;
for (int i = 1; i <= n; ++i) {
std::cin >> A >> B;
std::cout << "Case #" << i << ": " << A << " + " << B << " = " << A+B << "\n";
}
return 0;
}
Python
import sys
input = sys.stdin.readline
n = int(input())
for i in range(1, n+1):
A, B = list(map(int, input().split()))
print("Case #{}: {} + {} = {}".format(i, A, B, A+B))
[2438번] 9. 별 찍기 - 1
C++
#include <iostream>
#include <string>
int main(int argc, char* argv[])
{
int N;
std::cin >> N;
std::string str("*");
for (int i = 1; i <= N; ++i) {
str.resize(i, '*');
std::cout << str << "\n";
}
return 0;
}
Python
import sys
input = sys.stdin.readline
n = int(input())
for i in range(1, n+1):
print("*" * i)
[2439번] 10. 별 찍기 - 2
C++
#include <iostream>
#include <string>
int main(int argc, char* argv[])
{
int N;
std::cin >> N;
std::string str(" ");
for (int i = N; i >= 1; --i) {
str.resize(i-1, ' ');
str.resize(N, '*');
std::cout << str << "\n";
}
return 0;
}
Python
import sys
input = sys.stdin.readline
n = int(input())
for i in range(1, n+1):
print(" " * (n-i) + "*" * i)
[10871번] 11. X보다 작은 수
C++
#include <iostream>
int main()
{
std::ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
int n, x, a;
std::cin >> n >> x;
for (int i = 1; i <= n; ++i) {
std::cin >> a;
if (a < x) {
std::cout << a << " ";
}
}
return 0;
}
Python
import sys
input = sys.stdin.readline
n, x = list(map(int, input().split()))
A = list(map(int, input().split()))
for a in A:
if a < x:
print(a, end=' ')
[10952번] 12. A+B - 5
C++
#include <iostream>
int main()
{
std::ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
int A, B;
std::cin >> A >> B;
while (A != 0 && B != 0) {
std::cout << A+B << "\n";
std::cin >> A >> B;
}
return 0;
}
Python
import sys
input = sys.stdin.readline
A, B = list(map(int, input().split()))
while A != 0 and B != 0:
print(A+B)
A, B = list(map(int, input().split()))
[10951번] 13. A+B - 4
C++
#include <iostream>
int main()
{
int A, B;
while (true) {
std::cin >> A >> B;
if (std::cin.eof()) {
break;
}
std::cout << A + B << "\n";
}
return 0;
}
Python
import sys
input = sys.stdin.readline
for line in sys.stdin:
A, B = list(map(int, line.split()))
print(A+B)
[1110번] 14. 더하기 사이클
C++
#include <iostream>
int main()
{
std::ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
int num, sum_num, new_num, cnt;
cnt = 1;
std::cin >> num;
if (num < 10) {
new_num = 11*num;
}
else {
sum_num = num / 10 + num % 10;
new_num = num % 10 * 10 + sum_num % 10;
}
while (new_num != num) {
sum_num = new_num / 10 + new_num % 10;
new_num = new_num % 10 * 10 + sum_num % 10;
cnt++;
}
std::cout << cnt;
return 0;
}
Python
import sys
input = sys.stdin.readline
number, cnt = input().strip(), 0
if len(number) == 1:
number = "0"+number
sum_number = int(number[0]) + int(number[1])
new_number = number[-1] + str(sum_number)[-1]
cnt += 1
while new_number != number:
sum_number = int(new_number[0]) + int(new_number[1])
new_number = new_number[-1] + str(sum_number)[-1]
cnt += 1
print(cnt)