공부기록/SWEA

[SWEA] 2072번 홀수만 더하기

메델 2023. 10. 20. 21:37
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Solution {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		int T = Integer.parseInt(br.readLine());
		
		for(int i=0; i<T; i++) {
			int sum = 0;
			
			String[] inputNumbers = br.readLine().split(" ");
			
            for (String input : inputNumbers) {
                int num = Integer.parseInt(input);
                if (num % 2 != 0) {
                    sum += num;
                }
            }
			sb.append("#").append(i+1).append(" ").append(sum).append('\n');
			
		}
		System.out.println(sb.toString());

		
	}

}