import java.util.Scanner;
public class guess {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个整数范围在1——100之间");
int guessNum =(int)(Math.random()*100)+1;//生成随机数
while(true){
int result=sc.nextInt();
if(result>guessNum){
System.out.println("so bbbbbbig");
}
else if(result<guessNum){
System.out.println("so ssssmall");
}
else{
System.out.println("it is you !!");
break;
}
}
}
}
运行结果:
请输入一个整数范围在1——100之间 50 so ssssmall 70 so ssssmall 90 so bbbbbbig 80 so bbbbbbig 75 so bbbbbbig 74 it is you !!
Process finished with exit code 0
|