标签:weight else static -- print default 四则运算 rgs ++
public class sizeyunsuan { public static void main(String[] args) { Random random = new Random(); for (int j = 1; j <= 300; j++) { int algorithm = random.nextInt(4); int num1 = random.nextInt(100); int num2 = random.nextInt(100);
switch (algorithm) { case 0:
System.out.println("第" + j + "个:");
System.out.println(num1 + "*" + num2 + "=" ); break; case 1:
System.out.println("第" + j + "个:");
System.out.println(num1 + "+" + num2 + "=" ); break; case 2:
System.out.println("第" + j + "个:");
System.out.println(num1 + "-" + num2 + "=" ); break; case 3:
if (num2 == 0) {
j--; break; } else {
System.out.println("第" + j + "个:");
System.out.println(num1 + "/" + num2 + "=");
} break; default: break; } } }
}
标签:weight else static -- print default 四则运算 rgs ++
原文地址:http://www.cnblogs.com/xuzhinan/p/6518133.html