Contents

1 襦蠏碁 讌覲願鍵
2 谿瑚襭


譬.. 襷襷蠍磯 .. 讒.. 企給..

1 襦蠏碁 讌覲願鍵 #

2 谿瑚襭 #

import java.util.*;

public class WordScrambleEx1 {
	public static void main(String[] args){
		String[] strArr = {"change", "love", "hope", "view"};
		
		String answer = getAnswer(strArr); 
        String question = getScrambledWord(answer); 
        Scanner scan = new Scanner(System.in);
        
        System.out.println("讌覓: "+question); 
        for(;;){
        	System.out.print("給: ");
        	
        	String strIn;
        	strIn = scan.nextLine(); 
        	
        	if (strIn.equalsIgnoreCase("q"))
        		System.exit(0);
        	
        	if (strIn.equalsIgnoreCase(answer)){
        		System.out.println("豢. 旧!!");
        		System.out.println();
        		break;
        	}
        	else{
        		System.out.print("旧 . れ ロ語:");
        	}
        		
        		
        } //for
        
	} // main
	
	public static String getAnswer(String[] strArr){
		int rand = (int)(Math.random() * 10 % strArr.length);
		return strArr[rand];
	} //getAnswer
	
	public static String getScrambledWord(String str){	
		char[] chArr = str.toCharArray();
		char tmp;
		int rand;
		
		for(int i=0;i<str.length();i++){
			rand = (int)(Math.random() * 10 % str.length());
			tmp = chArr[i];
			chArr[i] = chArr[rand];
			chArr[rand] = tmp;
		}
		return new String(chArr);

	} //getScrambledWord
} //WordScrambleEx


import java.util.*;

public class QuizEx1 {

	public static void main(String[] args){
		String[] data = { 
                "れ 譴 れ螳  蟆?`2`final`True`if`public", 
                "れ 譴 覦 一一螳  蟆?`5`&`|`++`!=`/`^", 
                "れ 譴 覃 覦螳  覩誤 れ?`1`void`null`false", 
        };
		
		int[] answer = {2, 6, 1};
		int score = 0;
		Scanner s = new Scanner(System.in);
		shuffle(data);
		
		for(int i=0;i<data.length;i++){
			String[] strArr = data[i].split("`");
			
			for(int j=0;j<strArr.length;j++){
				switch(j){
					case 0 : 
						System.out.println("[" + (i+1) + "]" + strArr[j]);
						break;
					case 1 : 
						break;
					default :
						System.out.print(j-1 + "." + strArr[j] + " ");
				}
			}
			System.out.print("\r\n[]");
			
			if (answer[i] == Integer.parseInt(s.nextLine())){
				score++;
			}
					
			System.out.println("");
							
		} //for
		
		System.out.println("糾/豌企誤 : " + score + "/" + data.length);
	} //main
	
	public static void shuffle(String[] data){
		if (data.length > 0){
			int rand;
			String tmp;
			
			for(int i=0; i<data.length;i++){
				rand = (int)(Math.random() * 10 % data.length);
				tmp = data[i];
				data[i] = data[rand];
				data[rand] = tmp;
			}
		}
	} //shuffle
}