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