package com.company.practice1;
import java.util.Random;
import java.util.Scanner;
public class Practise1 {
public static void main(String[] args) {
System.out.println(“猜数迷游戏开始啦!”);
Scanner scanner = new Scanner(System.in);
Random random = new Random();
int computer = random.nextInt(100)+1;
System.out.println(“电脑生成的随机数为:”);
System.out.println(computer);
while(true)
{
System.out.println(“请玩家输入数:”);
int player = scanner.nextInt();
System.out.println(“玩家输入的数为:”+player);
if(player > computer)
System.out.println(“大了宝往小了猜讨厌!”);
else if(player <computer)
System.out.println(“小了宝,往大了猜”);
else {
System.out.println(“猜对了宝贝!”);
break;
}
}
}
}