class Guessnumber {
public static void main(String[]args) throws Exception {
int guess = (int)(Math.random()*21);
int ch = 0;
int input = 0;
int times = 0;
boolean isEnd = false;
while(true) {
ch = System.in.read();
switch(ch) {
case'\r':
break;
case'\n':
input/=10;
if(input>guess) {
System.out.println("Guess larger");
times++;
}
if(input<guess) {
System.out.println("Guess smaller");
times++;
}
if(input==guess&×<4) {
System.out.println("cool,you win!");
isEnd = true;
}
if(input!=guess&×==4) {
System.out.println("Sorry,you've guessed four times!you lose the game!");
isEnd=true;
System.out.println("the number is "+guess);
}
if(isEnd) {
times = 0;
guess = (int)(Math.random()*21);
isEnd = false;
}
input = 0;
break;
default:
input+=(ch-'0');
input*=10;
}
}
}
}
public static void main(String[]args) throws Exception {
int guess = (int)(Math.random()*21);
int ch = 0;
int input = 0;
int times = 0;
boolean isEnd = false;
while(true) {
ch = System.in.read();
switch(ch) {
case'\r':
break;
case'\n':
input/=10;
if(input>guess) {
System.out.println("Guess larger");
times++;
}
if(input<guess) {
System.out.println("Guess smaller");
times++;
}
if(input==guess&×<4) {
System.out.println("cool,you win!");
isEnd = true;
}
if(input!=guess&×==4) {
System.out.println("Sorry,you've guessed four times!you lose the game!");
isEnd=true;
System.out.println("the number is "+guess);
}
if(isEnd) {
times = 0;
guess = (int)(Math.random()*21);
isEnd = false;
}
input = 0;
break;
default:
input+=(ch-'0');
input*=10;
}
}
}
}