티스토리 뷰

반응형


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.util.Scanner;
 
//2072. 홀수만 더하기
public class Solution2072 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();    // 반복 횟수
        for(int i=0; i<T; i++) {
            int sum = 0;
            for(int j=0; j<10; j++) {    // 10개의 수 입력 
                int num = sc.nextInt();
                if(num%2 != 0)
                    sum = sum + num;
            }
            System.out.println("#"+(i+1)+" "+sum);
            sum = 0;
        }
    }
}
cs


--

3

3 17 1 39 8 41 2 32 99 2

22 8 5 123 7 2 63 7 3 46

6 63 2 3 58 76 21 33 8 1   


--

#1 200

#2 208

#3 121


반응형
댓글
최근에 올라온 글
최근에 달린 댓글
링크
Total
Today
Yesterday