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 |
Re:What's wrong with my code..??In Reply To:What's wrong with my code..?? Posted by:Steinersp at 2006-12-11 16:04:14 i Guess Class Main Have to be Public!!!! This run goog but gets Wrong Answer i Dont know why!!!! import java.io.*; import java.util.*; public class Main { public static boolean Existe (int Vec[], int c,int Num) { for (int i=1;i<=c;i++) if (Num == Vec[i]) return true; return false; } public static boolean Jolly (int Vec[], int c) { while (true) { for (int i=1;i<c;i++) { int Aux = Math.abs((Vec[i]-Vec[i+1])); boolean Sw = Existe (Vec,c,Aux); if (!Sw) { return false; } else return true; } return true; } } public static void main(String[] args) { try { BufferedReader Leer = new BufferedReader (new FileReader (new File ("Hola.txt"))); // BufferedReader Leer = new BufferedReader (new InputStreamReader (System.in)); while (true) { String Aux = Leer.readLine(); StringTokenizer Cadena = new StringTokenizer (Aux); int c = 1; int Opc = Integer.parseInt (Cadena.nextToken()); int Vec[] = new int [++Opc]; while (Cadena.hasMoreTokens()) { Vec[c] = Integer.parseInt (Cadena.nextToken()); c++; } c--; boolean Sw = Jolly(Vec,c); System.out.println (Sw ? "Jolly" : "Not jolly"); } } catch (Exception e) { //System.out.println ("Fuck "+e); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator