题解 | #统计数据正负个数#
统计数据正负个数
https://www.nowcoder.com/practice/3f33889582934a09b4e3ddd3cc976226
#include <stdio.h> int main() { int arr[10] = { 0 }; int z = 0 , f = 0; //z是正 f是负 for(int i = 0 ; i < 10 ; i ++) { scanf("%d",&arr[i]); //这样子搞就少写个for循环 合并起来 if(arr[i] > 0) z++; else if(arr[i] < 0) f++; } printf("positive:%d\n",z); printf("negative:%d\n",f); return 0; }