public class Test { public static void main(String sgs[]) { for(int i = 0; i 10; i++){ int x = (int) (Math.random() * 100 + 1); int y = (int) (Math.random() * 100 + 1); System.out.println(x + + + y + = + (x + y)); } }}
public class test { public static void main(String args[]) { int sum = 0; Random r = new Random(); Scanner in = new Scanner(System.in); long time = System.currentTimeMillis(); for (int i=0;i10;i++) { int a = r.nextInt(15)+1; int b = r.nextInt(15)+1; System.out.print(第 + (i + 1) + 道: + a + + + b + = ); int c = in.nextInt(); if (a + b == c) { sum++; } } time = System.currentTimeMillis() - time; System.out.println(答对了: + sum + 道题,花费了+ time + 毫秒); } }