返回题解分享
讨论 / 题解分享/ 帖子详情

奇偶统计 - 题解

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, sum1 = 0,sum2 = 0;//sum1为偶数统计,sum2为奇数统计
    while(cin >> n && n)//n不等于0便一直读入
    {
        if(n % 2 ==0) sum1++;
        else sum2 += n;
    }
    cout << sum1 <<endl;
    cout << sum2;
    return 0;
}
0 回复 0 转发 0 喜欢 2 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!