Page 1 of 1

Input data - Compile Error

Posted: Sun Oct 14, 2007 1:54 pm
by tmnq
Hi all,

Today I tried to submit answers to Columbus weekend Contest #4, but could not pass the "compile error".

Even when I did not include any external libraries. The judges still returned me "Compile error".

Here's my code:

Code: Select all

class Main {
	static String readLine() throws Exception
	{
		char c=' ';
		String str="";
		while (true)
		{
			c=(char) System.in.read();
			if (c=='\n') break;
			str+=c;
		}
		return str;		
	}
	public static void main(String args[]) throws Exception
	{		
		String str=readLine();
		String[] arr= str.split(" ");
		int n= Integer.parseInt(arr[0]);
		double t= Double.parseDouble(arr[1]);
		System.out.printf("Program 1 by team 11568\n");
		while (true)
		{
			str= readLine();
			arr= str.trim().split(" ");
			int a= Integer.parseInt(arr[0]);
			int b= Integer.parseInt(arr[1]);
			int c= a-b;
			if (c<0) c+=n;
			double r= ((float)c-0.5)/(float)(n-1)*t;
			System.out.printf("Chair %3d meets chair %3d, remaining time = %5.1f\n",a,b,r);
		}
	}
}
I have tried Scanner,BufferedInputStream, InputStreamReader and now System.in but always get "Compile Error". Why is it so??

i feel desperate.. Any help will be really appreciated!

Thank u in advance.

Posted: Sun Oct 14, 2007 8:11 pm
by Darko
On the old server (where that contest is) they use Java 1.1.
printf() came in 1.5 (so did String.split()) and I think there was no Double.parseDouble() in 1.1 either.

You should be getting emails after you submit to the old server, you can change that in your profile. It will tell you exactly what the compiler error is.

Posted: Mon Oct 15, 2007 5:03 am
by tmnq
Thanks a lot Darko.

I still wonder normally how people input an integer/double/string in this situation? We even need to write a small routine, just for input?

Posted: Sun Oct 21, 2007 7:34 am
by chunyi81
Try BufferedReader and StringTokenizer for input parsing. For printing, try the old System.out.print and System.out.println methods.

Posted: Tue Oct 23, 2007 4:25 pm
by tmnq
Thank you chunyi81.