import java.util.Random; import java.util.Scanner; public class You { public static void main(String[] args){ Random a = new Random(); int b = 1; int c = 90; int d = a.nextInt(b,c * 1); while (true){ System.out.println(String.format("请输入数字[%d - %d]:",b,c)); int t = new Scanner(System.in).nextInt(); if (t == d){ System.out.printf("恭喜你猜对了.%n"); break; } else if (t >d){ System.out.println("太大了"); }else { System.out.println("太小了"); } } } }