题解 | #记负均正II#
记负均正II
https://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62
import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double sum = 0, othersTotal = 0;
int counter = 0;
while (in.hasNextInt()) {
int number = in.nextInt();
if (number < 0) counter++;
else {
sum += number;
othersTotal++;
}
}
System.out.println(counter);
if(othersTotal!=0) System.out.printf("%.1f\n",sum/othersTotal);
else System.out.println(0.0);
}
}

