python study - beakjoon 문제풀기03 - 반복문

01-2739-구구단

a = int(input())
i = 1
while i < 10:
    print(f"{a} * {i} = {a*i}")
    i += 1

02-10950-A+B - 3

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

T = int(input())

i = 1
while i <= T:
    A, B = map(int, input().split())
    print(f"{A+B}")
    i += 1

03-8393-1부터 n까지 합

n = int(input())

x = 0
while n >= 1:
    x = x + n
    n = n - 1

print(x)

04-25304-영수증

TOTAL = int(input())
NUMBER_OF_STUFF = int(input())
SUM = 0

for i in range(0, NUMBER_OF_STUFF):
    PRICE, NUMBER = map(int, input().split())
    SUM = SUM + PRICE * NUMBER

if TOTAL == SUM:
    print("Yes")
else:
    print("No")

05-15552-빠른A+B

import sys

NUMBER = int(sys.stdin.readline())

for i in range(0, NUMBER):
    A, B = map(int, sys.stdin.readline().split())
    print(A+B)

06-11021-A+B - 7

A+B를 조금 더 아름답게 출력하는 문제

N = int(input())
TRY = 0
for i in range(0, N):
    A, B = map(int, input().split())
    TRY += 1
    print(f"Case #{TRY}: {A+B}")

07-11022-A+B - 8

A+B를 바로 위 문제보다 아름답게 출력하는 문제

N = int(input())
TRY = 0
for i in range(0, N):
    A, B = map(int, input().split())
    TRY += 1
    print(f"Case #{TRY}: {A} + {B} = {A+B}")

08-2438-별 찍기 - 1

N = int(input())
TRY = 1
for i in range(0, N):
    print('*'*TRY)
    TRY += 1

09-2439-별 찍기 -2

N = int(input())
TRY = 1
for i in range(0, N):
    print(' '*(N-TRY)+'*'*TRY)
    TRY += 1

10-10952-A+B - 5

0과 0이 입력으로 들어올 때까지 A+B를 출력하는 문제

while True:

A, B = map(int, input().split())

if A == 0 and B == 0:

break

print(A+B)

11-10951-A+B - 4

EOF 입력이 없을때까지 출력하기

while True:
    try:
        A, B = map(int, input().split())
        print(A+B)
    except:
        break

12-1110-더하기 사이클

N = int(input())
NEW = N
TRY = 0
while True:
    L = NEW // 10
    R = NEW % 10

    L_PLUS_R = (L + R) % 10

    NEW = R * 10 + L_PLUS_R
    TRY += 1
    if N == NEW:
        break

print(TRY)

댓글 쓰기

0 댓글