Random rd=new Random(); int num=rd.nextInt(100); System.out.println(num); while(true){ Scanner sc=new Scanner(System.in); int input=sc.nextInt(); if(input>num){ System.out.println("太大了,笨蛋"); }else if(input<num){ System.out.println("太小了,傻子"); }else{ System.out.println("恭喜你,走了狗屎运"); break; } count++; if(count==5){ System.out.println("不好意思 你没有机会了!"); break; } }