package shopping; import java.util.*; public class SendGiftMenu { public static void main(String[] args){ Random rnd = new Random(); Scanner input = new Scanner(System.in); int count = 0 ; System.out.println("我心里有一个0~99的整数,你猜是什么?"); while(true) { if(count > 20) break ; int num = rnd.nextInt(); num = num % 100 ; if(num < 0) continue ; else { while(true) { int gak_num = input.nextInt(); count++; if(count > 20) break ; if(gak_num == num) { System.out.println("猜对了!"); switch(count) { case 1:System.out.println("你太有才了!");break; case 2:case 3:case 4:case 5:case 6: System.out.println("这么快就猜出来了,很聪明嘛!"); break ; default: System.out.println("猜了半天才猜出来,小同志,尚需努力啊!"); break ; } } else { if(gak_num < num) System.out.println("小了点,再猜"); if(gak_num > num) System.out.println("大了点,再猜"); } } } } } }
时间: 2024-09-22 11:28:06