十一java作业1

花二十分钟写一个能自动生成30道小学四则运算题目的 “软件”。

package 练习;

import java.util.Random;

public class Int {
public static void main(String[] args) {
String[] operate=new String[]{"+","-","×","÷"};
int[] numbers=new int[100];
for(int i=1;i<=100;i++){
numbers[i-1]=i;
}
Random r=new Random();
for(int i=0;i<30;i++){
System.out.println(numbers[r.nextInt(100)]+operate[r.nextInt(4)]+numbers[r.nextInt(100)]+"=");
}
}
}

41÷63=
96+50=
92×97=
76×97=
77×34=
11×9=
18-87=
16×73=
49-72=
10×1=
83-38=
49+58=
5+26=
32-78=
86+73=
49+65=
53+44=
42+47=
28÷9=
49+89=
83+19=
96÷69=
61+90=
66+66=
32+22=
52-74=
16-49=
93+27=

猜你喜欢

转载自www.cnblogs.com/gkl20173667/p/9750584.html