题解 | #记负均正II#
记负均正II
https://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
List<Integer> low = new ArrayList<>();
List<Integer> up = new ArrayList<>();
while (sc.hasNextInt()){
int in = sc.nextInt();
if (in < 0 ){
low.add(in);
}else{
up.add(in);
}
}
System.out.println(low.size());
float temp = 0.0f;
if (up.size()==0){
System.out.println(0.0f);
}else {
for (Integer num :up) {
temp+=num;
}
System.out.println(String.format("%.1f",temp/up.size()));
}
}
}

