东方博弈 1174-求和

package Oj;

import java.util.Scanner;

public class demo_1174 {
    public static void main(String[] args) {
//        1174 - 求和
        Scanner input = new Scanner(System.in);
        int num = input.nextInt();
        int[] arr = new int[num];
        for (int i = 0; i < arr.length; i++) {
            arr[i]= input.nextInt();
        }
        int even=0 ,odd =0;//even偶数
        for (int i = 0; i < arr.length; i++) {
            if(arr[i]%2==0){
                even+=arr[i];
            }
            else{
                odd+=arr[i];
            }
        }
        System.out.println(odd+"\n"+even);
    }
}

你可能感兴趣的:(java,算法,开发语言)