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 |
Re:谁帮帮忙,哪里错了 javaIn Reply To:谁帮帮忙,哪里错了 java Posted by:yanical at 2006-09-01 21:25:40 > 本来以为会超时,试了下,没有,确错了 > 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator