import java.io.*;
class Test{
public static void main(String args[]){
int seikai = 1484;
int count;
int inp = -1;
for( count = 1 ; count <= 10 ; count++ ){
inp = -1;
while( inp < 0 || inp > 9999 )
inp = readNumber();
if( inp == seikai ){
System.out.println(count + "回目で正解ですね");
break;
}
if( inp < seikai )
System.out.println("小さい");
else
System.out.println("大きい");
}
if( inp != seikai )
System.out.println("10回で正解しませんでした。ゲームオーバー");
}
// キーボードから数字を入力するメソッド
public static int readNumber(){
byte b[] = new byte[100];
try{
System.in.read(b);
return Integer.parseInt((new String(b)).trim());
}catch(Exception e){
return 0;
}
}
}
|