본문 바로가기
Algorithm/swea

swea 2072. 홀수만 더하기

by 갈잃자 2022. 8. 22.

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5QSEhaA5sDFAUq 

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


테스트케이스가 주어지고

 

주어진 숫자들 중, 홀수만 찾아 더하여 출력하는 문제이다.

t = int(input())
for tc in range(1,t+1):
    arr = list(map(int,input().split()))
    result = 0
    for i in range(10):
        if arr[i]%2 ==1:
            result+=arr[i]
    print(f'#{tc} {result}')

댓글