mian(){
float s1=0,s2=0,x;
int n1=0,n2=0,i;
for(i=0;i<10;i++)
{scanf("%f",&x);
if(x>0){s1+=x;n1++;}
if(x<0){s2+=x;n2++;}
}
printf("所有正数和=%f,平均值=%f\n",s1,s1/n1);
printf("所有负数和=%f,平均值=%f\n",s2,s2/n2);
}
#include "stdio.h"
void main()
{ int i,sumpn=0,sumen=0;
float n,sump=0,sume=0;
for(i=0;i<10;i++)
{ scanf("%f",&n);
if(n>=0)
{
sump+=n;
sumpn++;
}
else
{
sume+=n;
sumen++;
}
}
printf("正数和=%f,平均值=%f\n",sump,sump/sumpn);
printf("负数和=%f,平均值=%f\n",sume,sume/sumen);
}
gbd