标题: 猜数字小游戏, [打印本页] 作者: 坏坏坏男孩 时间: 2016-7-12 21:35 标题: 猜数字小游戏, import java.util.*;
class numGame2{
public static void main(String[] args) {
int guessNumber=(int)(Math.random() * 100)+1;
Scanner Sc =new Scanner(System.in);
System.out.print("亲爱哒,请输入一个辛运数字吧:");
int max=100;
int min=0;
while (true) {
int result = Sc.nextInt();
if (result > guessNumber) {
max = result;
System.out.println("不对哦,再接再厉哦.请在"+max+"和"+min+"之间重新输入您的幸运数字吧:");
}else if (result <guessNumber) {
min = result;
System.out.print("不对哦,加油哦,请在"+min+"和"+max+"之间重新输入您的幸运数字吧:");