##随机10道10以内的+ - 法
public static void main(String[] args) { Random r = new Random(); for (int i = 0; i < 11; i++) { int num1 = 0 + r.nextInt(10); int num2 = 0 + r.nextInt(10); int x = 0 + r.nextInt(2); int count = 0; if (x == 0) { System.out.println(num1 + "+" + num2 + "=?"); Scanner sc = new Scanner(System.in); int daan = sc.nextInt(); if (daan == num1 + num2) { System.out.println("Y"); count++; } else { System.out.println("N"); } } else { System.out.println(num1 + "-" + num2 + "=?"); Scanner sc = new Scanner(System.in); int daan = sc.nextInt(); if (daan == num1 - num2) { System.out.println("Y"); count++; } else { System.out.println("N"); } } if (i == 10) { System.out.println(count +"/"+ 10); } } }
随机10道10以内的+ - 法
于 2022-01-25 14:25:59 首次发布