题解 | #统计数据正负个数#

统计数据正负个数

https://www.nowcoder.com/practice/3f33889582934a09b4e3ddd3cc976226

#include <stdio.h>
int main() 
{
    int i=10;
    int a=0;
    int positive=0;
    int negative=0;
    //输入十个数
    while(i)
    {
        scanf("%d",&a);
        //统计正负数的个数
        if(a>0)
        {
            positive++;
        }
        if(a<0)
        {
            negative++;
        }
        i--; 
    }
    printf("positive:%d\nnegative:%d",positive,negative);
    return 0;
}

全部评论

相关推荐

06-07 19:59
门头沟学院 C++
补药卡我啊😭:都快15年前的了还在11新特性
你的简历改到第几版了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务