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