你的程序要读入一系列正整数数据,输入-1表示输入结束,-1本身不是输入的数据。程序输出读到的数据中的奇数和偶数的个数。


#include<stdio.h>

int main()
{
    int n;
    int oushu=0;
    int jishu=0;
    while(scanf("%d",&n))
    {
        if (n==-1) break;
        if(n%2==0)
        {
            oushu++;
        }
        else
        {
            jishu++;
        }
    } 
    printf("%d %d\n",jishu,oushu);
    return 0;
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM