题解 | #记负均正II#
记负均正II
http://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62
牛客前面一道的变式
#include <algorithm>
#include <iomanip>
using namespace std;
int main() {
int temp,negative=0,positive=0;
double sum=0;
while(cin>>temp){
if(temp<0)negative++;
else if(temp>=0) {
sum+=temp;
positive++;
}
}
cout<<negative<<endl;
if(positive)cout<<fixed<<setprecision(1)<<sum/positive<<endl;
else cout<<fixed<<setprecision(1)<<0.0<<endl;
}