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

why RuntimeError, my Java code? Use Cpp and get Accept

Posted by WhoKnows at 2006-04-27 12:32:59 on Problem 1053
import 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:
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