Codeup_575D_比较奇偶数个数

题目描述

第一行输入一个数,为n,第二行输入n个数,这n个数中,如果偶数比奇数多,输出NO,否则输出YES。

输入

输入有多组数据。
每组输入n,然后输入n个整数(1<=n<=1000)。

输出

如果偶数比奇数多,输出NO,否则输出YES。

样例输入

1
67 
7
0 69 24 78 58 62 64 

样例输出

YES
NO


注意:YES和NO都是大写;
AC代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define Max 50 
using namespace std;

int main(void)
{
    freopen("in.txt","r",stdin);
    
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int t1=0,t2=0;
        long long temp;
        for(int i=1;i<=n;i++)
        {
            scanf("%lld",&temp);
            if(temp%2==0)
                t1++;
            else
                t2++;
        }
        if(t1>t2)
            printf("NO
");
        else
            printf("YES
");
    }
    
    
    fclose(stdin);
    return 0;
}
原文地址:https://www.cnblogs.com/phaLQ/p/10056714.html