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

Re:run-time error...java求救

Posted by mengxiaoyan at 2009-11-29 12:02:11 on Problem 1005
In Reply To:run-time error...java求救 Posted by:6503548 at 2009-11-20 16:30:54
> import java.util.Scanner;
> public class EX1005 {
> 
>     public static void main (String[] args) {
>     	Scanner keyboard=new Scanner(System.in);
>     	int N=keyboard.nextInt();
>     	int []p=new int[N];
>     	for (int i=0;i<N;i++) {
>     		double x=keyboard.nextInt();
>     		double y=keyboard.nextInt();
>     		double r0=Math.sqrt(x*x+y*y);
>     		int j;
>     		for (j=1;;j++) {
>     			if (Math.sqrt(100*j/Math.PI)>r0) {
>     				break;
>     			}
>     		}
>     		p[i]=j;
>     		
>     	}
>     	for (int i=1;i<=N;i++) {
>     		System.out.println("Property "+i+": This property will begin eroding in year "+p[i-1]+".");
>     	}
>     	System.out.println("END OF OUTPUT.");
>     }
>     
>     
> }
把程序里的next.int改成nextDouble就可以了,我试过了。

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