ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ import java.util.*; public class Test{ public static void main(String[] args){ Scanner in=new Scanner(System.in); Random rd=new Random(); int a =rd.nextInt(101); int number; do{ System.out.println("请猜一下电脑随机生成的数"); number=in.nextInt(); if(number<a){ System.out.println("小了"); }else if(number>a){ System.out.println("大了"); } }while(number!=a); System.out.println("恭喜你,猜对了"); } } ~~~