#include<stdio.h>
int main()
{
int i = 0;
int a = 0;
int j = 0;
int sum = 0;
printf("输入整数,为0时结束:");
scanf("%d", &j);
if(j < 0)
i++;
else if(j > 0)
{
a++;
sum = sum + j;
}
while (j)
{
scanf("%d", &j);
if(j < 0)
i++;
else if (j > 0)
{
a++;
sum = sum + j;
}
}
printf("负数个数:%d", i);
printf("正数个数:%d", a);
printf("正数之和:%d", sum);
}
c语言--输入整数,以0而结束,统计正数个数
![](https://img-home.csdnimg.cn/images/20240711042549.png)