import java.util.Random;
import java.util.Scanner;
public class gameDemo{
public static void main(String[] args){
Random r = new Random();
int i = r.nextInt(100);
System.out.println("请输入您猜的数字");
Scanner sc = new Scanner(System.in);
int enterNumber = sc.nextInt();
while(enterNumber != i){
//System.out.println("恭喜您,答对了");
if(enterNumber > i){
System.out.println("您猜大了");
}else{
System.out.println("您猜小了");
}
//Scanner sc = new Scanner(System.in);
enterNumber = sc.nextInt();
}
System.out.println("恭喜您,答对了"); |
|