题解 | #统计数据正负个数#
统计数据正负个数
http://www.nowcoder.com/practice/3f33889582934a09b4e3ddd3cc976226
#include<stdio.h> int main() { int count_p=0,count_n=0; int a[10]; int i=0; for(i=0;i<10;i++){ scanf("%d ",&a[i]); } for(i=0;i<10;i++){ if(a[i]>0){ count_p++; } if(a[i]<0){ count_n++; } } printf("positive:%d\nnegative:%d\n",count_p,count_n); return 0; }