B4063 [GESP202412 一级] 奇数和偶数题解

· · 题解

#include<bits/stdc++.h>//万能头上场
using namespace std;
int main(){
    long long sum;//定义个数
    cin>>sum;//输入个数
    int cnt,cut;//定义两个变量来计数
    cnt=0;//奇数计数
    cut=0;//偶数计数.
    for (int i=1;i<=sum;i++){//遍历1-sum之间输入的数字
        long long s;//定义数字s
        cin>>s;//重复输入s
        if (s%2==0){
            cut++;//如果判断为偶数计数加一
        }
        if (s%2==1){
            cnt++;//如果判断为奇数计数甲乙
        }
    }
    cout<<cnt<<" "<<cut;//最后先观察格式先输出奇数个数在来个空格最后输出偶数个数
    return 0;//AC过来
}