题解 | #记负均正II#
记负均正II
http://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
int count_nag=0;
int count_pos=0;
double sum=0.0;
while(in.hasNextDouble()){
double a=in.nextDouble();
if(a<0) count_nag++;
else{
sum+=a;
count_pos++;
}
}
System.out.println(count_nag);
if(count_pos==0) System.out.println(0.0);
else
System.out.printf("%.1f\n",sum/count_pos);
}
}