본문 바로가기

[SW][BEAKJOON]/[SW][BEAKJOON][반복문]

(14)
[BEAKJOON][반복문][2439][Python] 별 찍기 - 2 PROBLEM - Link Approach to the problem - Code n = int(input()) # 1부터 n까지 for i in range(1, n+1): # (최종 갯수 - 현재 갯수) = 공백 갯수 print(' ' * (n-i) + '*' * i) End -
[BEAKJOON][반복문][10950][Python] A+B - 3 PROBLEM - Link Approach to the problem - Code # 첫줄에 Test 횟수 입력 # 그 다음 2개의 숫자 덧셈 T = int(input()) for i in range(T): A,B = map(int,input().split()) print(A+B) End -
[BEAKJOON][반복문][2742][Python] 기찍 N PROBLEM - Link Approach to the problem - Code # count가 거꾸로 되는 경우 # 2개씩도 가능 a = int(input()) for i in range(a, 0, -1): print(i) # 뺄셈을 통한 한단계식 거꾸로 갈 수 있음 N=int(input()) for i in range(N): print(N-i) End -
[BEAKJOON][반복문][10952][Python] A+B - 5 PROBLEM - Link Approach to the problem - Code while True: a, b = map(int, input().split()) # 마지막 숫자는 0 0 if a == b == 0: break print(a+b) End -
[BEAKJOON][반복문][1110][Python] 더하기 사이클 PROBLEM - Link Approach to the problem - 숫자 자리수 (두자리 수) = (십의자리 수 * 10) + (일의자리 수) 여기서 (일의자리 수) = (십의자리 수 / 10) 의 나머지 Code input_num = int(input()) # num 변수에 input_num을 지정 num = input_num # 횟수 Count를 위한 변수 cnt 선언 & 초기 cnt = 0 while True: sum_num = (num // 10) + (num % 10) # 각 자릿수를 더한수 new_num = ((num % 10) * 10) + (sum_num % 10) # 새로 만들어지는 수 cnt += 1 # 사이클 카운트 if new_num == input_num : break num..
[BEAKJOON][반복문][11022][Python] A+B - 8 PROBLEM - Link Approach to the problem - Code T = int(input()) #Default는 0부터 시작이기 때문에 숫자를 세기 위해서는 1~입력+1 for i in range(1, T+1): A, B = map(int, input().split()) print("Case #" + str(i) + ":", A, "+", B, "=", A+B) End -
[BEAKJOON][반복문][8393][Python] 합 PROBLEM - Link Approach to the problem - Code # 입력 : n이 주어진다 (1~10000) # 1~n 까지의 합을 출력 n = int(input()) for i in range(n+1) sum = sum + i print(sum) End -
[BEAKJOON][반복문][10951][Python] A+B - 4 PROBLEM - Link Approach to the problem - Code #조건이 완료될 때 까지 반복 while True: try: A, B = map(int, input().split()) print(A+B) except: break End -
[BEAKJOON][반복문][10871][Python] X보다 작은 수 PROBLEM - Link Approach to the problem - Code count, num = map(int, input().split()) # 위치에 따른 비교가 필요하기 때문에 배열로 저장해서 확인 예정 inArr = list(map(int, input().split())) for i in range(count): if inArr[i] < num: print(inArr[i], end=" ") # ----------- # 배열 만드는 다른 방법 (List 사용하지 않음) N, x = map(int, input().split()) a = map(int, input().split()) c = [] for i in a: if i
[BEAKJOON][반복문][2438][Python] 별 찍기 - 1 PROBLEM - Link Approach to the problem - Code n = int(input()) # 1부터 n까지 for i in range(1, n+1): # 문자열 * 숫자 = 횟수만큼 문자열 출력 print('*' * i) End -