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 |
What's wrong with my code..??I got Runtime Error... and I don't know why...!! I run the program on my PC and It runs perfect... Please help me... import java.io.*; import java.util.*; class Main { static int jolly[]; static int jumper[]; public static boolean judge() { for (int i = 0; i < jumper.length; i ++) if (jumper[i] != (i + 1)) return false; return true; } public static void main(String args[]) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String linea; while ((linea = in.readLine()) != null) { int index = linea.indexOf(' '); int n = new Integer(linea.substring(0, index)); String token[] = linea.substring(index + 1, linea.length()).split("\\s"); jolly = new int[n]; for (int i = 0; i < n; i ++) jolly[i] = new Integer(token[i]); jumper = new int[n - 1]; for (int i = 0; i < n - 1; i ++) jumper[i] = Math.abs(jolly[i] - jolly[i + 1]); Arrays.sort(jumper); if (judge()) System.out.println("Jolly"); else System.out.println("Not jolly"); } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator