题解 | #记负均正#
记负均正
http://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8
注意输出格式
#include <algorithm>
#include <iomanip>
using namespace std;
int main() {
int n;
while(cin>>n){
int temp,negative=0,positive=0;
double sum=0;
for(int i = 0;i<n;i++){
cin>>temp;
if(temp<0)negative++;
else if(temp>0) {
sum+=temp;
positive++;
}
}//for
cout<<negative<<' ';
if(positive)cout<<fixed<<setprecision(1)<<sum/positive<<endl;
else cout<<fixed<<setprecision(1)<<0.0<<endl;
}
}