Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

java 输出都对为什么还是错呢 谁帮我看下 谢谢了

Posted by gedoua at 2009-07-28 15:15:37 on Problem 2350
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator