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