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 |
why RuntimeError, my Java code? Use Cpp and get Acceptimport java.util.*; public class Main{ public static void main(String args[]) throws Exception { new SetMe(new Scanner(System.in)); } } class SetMe{ SetMe(Scanner cin){ char Card[][] = new char[1024][8]; int nCard; String Line; boolean Flag = true; while(true){ if(Flag) Flag = false; else System.out.println(); nCard = 0; while(true){ Line = cin.nextLine(); if(Line.length()==0) break; Card[nCard++] = Line.toCharArray(); } if(nCard==0) break; System.out.print("CARDS: "); for(int i = 0; i < nCard; i++){ System.out.print(" "+String.valueOf(Card[i])); } System.out.println(); int nSet = 1; for(int i = 0; i < nCard; i++){ for(int j = i+1; j < nCard; j++){ for(int k = j+1; k < nCard; k++){ boolean OK = true; for(int t = 0; t < 4; t++){ OK &= Card[i][t]==Card[j][t]&&Card[i][t]==Card[k][t]&&Card[j][t]==Card[k][t] || Card[i][t]!=Card[j][t]&& Card[i][t]!=Card[k][t]&& Card[j][t]!=Card[k][t]; } if(!OK) continue; if(nSet==1){ System.out.print("SETS: "); } else{ System.out.print(" "); } System.out.println((nSet++)+". "+String.valueOf(Card[i])+" "+ String.valueOf(Card[j])+" "+ String.valueOf(Card[k])); } } } if(nSet==1){ System.out.println("SETS: *** None Found ***"); } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator