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

统计数据正负个数

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

#include <stdio.h>

int main() {
    int positive = 0,negative = 0;
    int num[10] = {0};
    for(int i = 0;i<10;i++)
    {   
        scanf("%d",&num[i]);
        if(num[i] > 0)
        {
         positive++;
        }
        else
        {
          negative++;  
        }
    }
    printf("positive:%d\nnegative:%d",positive,negative);
    return 0;
}

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务