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

runtime error

Posted by UnleashYourPotential at 2011-05-27 11:04:05 on Problem 1939
为什么用java写的总是runtime error???

import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		long[] x;
		long[] y;
		int num;
		DecimalFormat df = new DecimalFormat("#.000000");
		while(true){
			num = in.nextInt();
			x=new long[num];
			y=new long[num];
			StringBuffer sb = new StringBuffer();
			
			sb.append(num+" ");
			for(int i = 0;i<num;i++){
				x[i]=in.nextLong();
				y[i]=in.nextLong();
			}
			
			for(int i=0;i<num-1;i++){
				sb.append(df.format((x[i]+x[i+1])/2)+" ");
				sb.append(df.format((y[i]+y[i+1])/2)+" ");
			}
		     
			sb.append(df.format((x[0]+x[num-1])/2)+" ");
			sb.append(df.format((y[0]+y[num-1])/2)+"\n");
			System.out.print(sb);
			
		}
		
	
		
	}

}

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