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 yanical at 2006-09-01 21:25:40 on Problem 2833
本来以为会超时,试了下,没有,确错了
import java.util.*;
import java.text.*;
public class Main 
{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n1=sc.nextInt();
		int n2=sc.nextInt();
		int n=sc.nextInt();
		while(n1!=0&&n2!=0&&n!=0)
		{
			int data[]=new int[n];
			for(int i=0;i<n;i++)
				data[i]=sc.nextInt();
			Arrays.sort(data);
			long sum=0;
			n=n-n1;
			for(int i=n2;i<n;i++)
				sum+=data[i];
			float result=(float)sum/(n-n2);
			
			DecimalFormat df=new DecimalFormat("#.000000");
			
			System.out.println(df.format(result));
			n1=sc.nextInt();
			n2=sc.nextInt();
			n=sc.nextInt();
		}
	}
}

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