import java.util.Scanner;
public class NumberGuessV01 {
public static void main(String[] ages){
//生成随机数
int num = (int)(Math.random()*1000)+1;
System.out.println(num);
//第一次猜测
System.out.println("请输入要猜的数字,退出按0:");
Scanner sc = new Scanner(System.in);
int guest = sc.nextInt();
//如果猜错,则继续
while(guest != num){
//输入0退出循环
if(guest == 0){
break;
}else if(guest > num){
System.out.println("输入的值太大了1");
}else {
System.out.println("输入的值太小了!");
}
System.out.println("输入要猜的数字,0退出:");
guest = sc.nextInt();
}
//提示用户结果
if(guest == num){
System.out.println("恭喜猜对");
}else{
System.out.println("很遗憾下次挑战");
}
sc.close();
}
}