package d6;
import java.util.Scanner;
public class yingbi {
public static void main(String[] args) {
Scanner d = new Scanner(System.in);
System.out.println("欢迎你进入到猜数游戏");
System.out.println("请输入1-100之间的任意一个数字");
int number=d.nextInt();
int random=(int)(Math.random()*100);
long start = System.currentTimeMillis();
while (number!=random){
if (number > random) {
System.out.println();
System.out.println("大了,请继续输入一个数:");
number=d.nextInt();
}else if(number<random){
System.out.println();
System.out.println("小了,请继续输入一个数:");
number=d.nextInt();
}
}
if (number == random) {
System.out.println("恭喜你猜中了");
long end = System.currentTimeMillis();
System.out.println("猜字所用时间是"+(end-start)+"毫秒");
}
}
}
01-20
6799
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)