zhu6231169 2025-09-13 9:58:00 6

#include using namespace std; int main(){ int n;cin>>n; int cnt1=0,cnt2=0; for(int i=1;i<=n;i++){ int x;cin>>x; if(x%2==0) cnt2++; else cnt1++; } cout<<cnt1<<" "<<cnt2; return 0; }

{{ vote && vote.total.up }}

共 1 条回复

wc02222

头文件写错的都来了,那你代码加个头文件就行了

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int cnt1 = 0, cnt2 = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x % 2 == 0)
            cnt2++;
        else
            cnt1++;
    }
    cout << cnt1 << " " << cnt2;
    return 0;
}

可以直接复制粘贴,反正就在你的代码上加了个“<bits/stdc++.h>”下次记得用这个格式的头文件,不然会被其他大佬嘲讽