1 Random使用
略
2 猜数字
Random random = new Random(); int i = random.nextInt(10); Scanner scanner = new Scanner(System.in); while (true){ int x = scanner.nextInt(); if (x>i){ System.out.println("大了"); }else if(x<i){ System.out.println("小了"); }else if(x==i){ System.out.println("恭喜你答对了"); break; } }
3 idea使用
略