题解 | #记负均正#
记负均正
http://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n = sc.nextInt();
int[] arr = new int[n];
for(int i = 0; i < n; i++){
arr[i] = sc.nextInt();
}
int count1 = 0, sum = 0, count2 = 0, count0 = 0;
for(int i = 0; i < n; i++){
if(arr[i] < 0) count1++;
if(arr[i] > 0){
sum += arr[i];
count2++;
}
if(arr[i] == 0){
count0++;
}
}
if(count0 == arr.length){
System.out.println(count1 + " " + "0.0");
}else{
System.out.println(count1 + " " + String.format("%.1f", sum * 1.0 / count2) + "\n");
}
}
}
}