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