题解 | #统计数据正负个数#
统计数据正负个数
http://www.nowcoder.com/practice/3f33889582934a09b4e3ddd3cc976226
#include<stdio.h> int main(){ int n = 0; int i = 0;//计正数 int j = 0;//计负数 int x = 10;//数字总个数 while(x) { scanf("%d ",&n); if(n > 0) i++; if(n < 0) j++; x--; }; printf("positive:%d\n",i); printf("negative:%d\n",j); return 0; }