四则运算第一阶段
2021-09-24
package sizeyunsuan;
import java.util.Random;
import java.util.Scanner;
public class sizeyunsuanyi {
public static void main(String[] args) {
int []a=new int[100];
int []b=new int[100];
Scanner scan =new Scanner(System.in);
int n;
System.out.println("请输入需要的题目数:");
n=scan.nextInt();
int i,j;
for(i=0;i<n;i++)
{
Random r=new Random();
a[i]=r.nextInt(99);
b[i]=r.nextInt(99);
for(j=0;j<i;j++) {
if(a[i]==b[j]&&b[i]==a[j]) {
a[i]=r.nextInt(99)-1;
}
}
int t=(int)r.nextInt(4);
switch(t)
{
case 0:
System.out.println(a[i]+" + "+b[i]+"=");
break;
case 1:
System.out.println(a[i]+" - "+b[i]+"=");
break;
case 2:
System.out.println(a[i]+" * "+b[i]+"=");
break;
case 3:
System.out.println(a[i]+" / "+b[i]+"=");
break;
}
}
}
}