题解 | #记负均正II#
记负均正II
http://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
int d;
int fcount=0;
double ave=0.0;
int zcount=0;
int sum=0;
while(cin>>d)
{
if(d<0)
{
fcount++;
}
else
{
zcount++;
sum+=d;
}
}
cout<<fcount<<endl;
if(zcount>0)
{
ave=(sum*1.0)/zcount;
}
printf("%.1lf\n",ave);
return 0;
}