小学四则运算题目代码

import java.*;

public class SS {
java.util.Random random=new java.util.Random();//产生随机数
public void set()
{
for(int a=1;a<=30;a++) {

if(a==1||a-4*((a-1)/4)==1) {
int n=random.nextInt(50)+1;
int m=random.nextInt(50)+1;

System.out.println(n+"+"+m+"=");
}
if(a==2||a-4*((a-2)/4)==2){
int n=random.nextInt(50)+25;
int m=random.nextInt(25)+1;
System.out.println(n+"-"+m+"=");
}
if(a==3||a-4*((a-3)/4)==3) {
int n=random.nextInt(10)+1;
int m=random.nextInt(10)+1;
System.out.println(n+"*"+m+"=");
}
if(a==4||a-4*((a-4)/4)==4) {
int n=random.nextInt(10)+5;
int m=random.nextInt(5)+1;
System.out.println(n+"/"+m+"=");
}
}
}
public static void main (String[] args)
{
SS b=new SS();
b.set();
}
}

猜你喜欢

转载自www.cnblogs.com/lover995/p/9753193.html
今日推荐