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

把 cin=new Scanner(System.in); 放到循环外面试试。

Posted by Judas at 2006-07-21 16:57:55 on Problem 1004
In Reply To:(java)为什么我的在自己的机器上没问题,但是提交通不过阿?(帮我看看) Posted by:nabber_jocelyn at 2006-07-21 16:40:13
> import java.io.*;
> import java.util.*;
> import java.text.DecimalFormat;
> 
> 
> public class Main
> {
>             public static void main(String args[])
>             {
>                     Scanner cin;
>                     double read=0;
>                     double result=0;
>                     DecimalFormat format=new DecimalFormat("#0.##");
>                     
>                        
>                     
>                     for(int count=1;count<=12;count++)
>                     {
>                     	
>                     	cin=new Scanner(System.in);
>                     	
>                     	read=cin.nextDouble();
>                     	result=result+read;
>                     	
>                     }
>                     System.out.print("$"+format.format(result/12));	
>                     	
>                     	
>             }
> } 

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