A - Yet Another Tetris Problem

A - Yet Another Tetris Problem

 

 

 

 

 

 思路:判读一堆数字是不是同奇数偶数,写一个函数,循环遍历,然后判断是否同为奇数偶数。

代码:

#include<iostream>

using namespace std;
int a[1005];

int fun(int n){
    int i;
    for (int i = 0; i < n; i++){
        if (a[i] % 2 != a[0] % 2)
            return 0;
    }
    return 1;
}

int main(){

    int n;
    cin >> n;
    while (n--){
        int x;
        cin >> x;
        for (int i = 0; i < x; i++)
            cin >> a[i];
        if (fun(x) == 1)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }

    system("pause");
    return 0;
}

 

posted @ 2020-03-15 18:07  PCDL&TIPO  阅读(147)  评论(0编辑  收藏  举报