Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
java 输出都对为什么还是错呢 谁帮我看下 谢谢了import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Scanner; public class Test2350 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int testN = s.nextInt(); int j = 0; while(j<testN) { int number = s.nextInt(); int d = 0; double[] score = new double[number]; double sum = 0; double result =0; while(d<number) { score[d] = s.nextFloat(); sum += score[d]; d++; } double average = sum/number; for(int i=0; i<number; i++) { if(score[i] > average) result++; } double sa = result/number; DecimalFormat df = new DecimalFormat("##.000"); String last = df.format(sa*100); System.out.println(last + "%"); j++; } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator