题解 | #统计数据正负个数#
统计数据正负个数
https://www.nowcoder.com/practice/3f33889582934a09b4e3ddd3cc976226
#include <stdio.h>
int main() {
//变量p,n分别用于记录正负数个数
int p = 0;
int n = 0;
//用于存放输入的数据
int arr[10];
for(int i = 0; i < 10; i++){
scanf("%d",&arr[i]);
if(arr[i] > 0)
p++;
else
n++;
}
printf("positive:%d\nnegative:%d",p,n);
return 0;
}

查看1道真题和解析