题解 | #统计数据正负个数#
统计数据正负个数
https://www.nowcoder.com/practice/3f33889582934a09b4e3ddd3cc976226
#include <stdio.h> int main() { int a; int b=0; int c=0; while (scanf("%d",&a)!=EOF) { if(a<0) b++; else if(a>0) c++; } printf("positive:%d\n",c); printf("negative:%d\n",b); } //直接来个输入的循环嵌套if语句这样感觉一举两得