题解 | #统计数据正负个数#
统计数据正负个数
http://www.nowcoder.com/practice/3f33889582934a09b4e3ddd3cc976226
int main()
{
int n, pos = 0, neg = 0;
char a;
while ((a = scanf("%d", &n)) != -1)
{
if (n > 0)
{
pos++;
}
if (n < 0)
{
neg++;
}
}
printf("positive:%d\nnegative:%d", pos, neg);
return 0;
}