题解 | #统计数据正负个数#
统计数据正负个数
https://www.nowcoder.com/practice/3f33889582934a09b4e3ddd3cc976226
#include <stdio.h> int main() { int a = 0; int p = 0; int n = 0; int count = 0; while (scanf("%d", &a) != EOF) { getchar(); if (a < 0) { n += 1; } if (a >= 0) { p += 1; } } printf("positive:%d\n", p); printf("negative:%d", n); return 0; }