题解 | #记负均正#
记负均正
http://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws InterruptedException {
Scanner sc=new Scanner(System.in);
int fs=0;
int zs=0;
float avg=0;
Integer n=sc.nextInt();
int[] nums=new int[n];
for (int i = 0; i < n; i++) {
int x=sc.nextInt();
if(x>0){
zs++;
avg+=x;
}
if(x<0){
fs++;
}
}
if(zs==0){
System.out.format("%d %.1f",fs,0.0);
}else{
System.out.format("%d %.1f",fs,avg/zs);
}
}
}
查看10道真题和解析