让人头疼的小学运算题
今天我终于知道小学运算题是怎么来的了!!!
小学生算300道运算题可能要一天,而出题人可能编程只要半个小时!
package text1;
public class P1 {
public static void gs(Object obj){
System.out.println(obj);
}
public static void main(String[] args){
int count = 0;
for(int i=0;i<300;i++){
int a = (int)(Math.random()*100);//随机数
int b = (int)(Math.random()*100);
int c = (int)(Math.random()*100);
int j=1;
if(0<=c&&c<10)
j=1;
else if(10<=c&&c<20)
j=2;
else if(20<=c&&c<30)
j=3;
else if(30<=c&&c<40)
j=4;
else if(40<=c&&c<50)
j=5;
else if(50<=c&&c<60)
j=6;
else if(60<=c&&c<70)
j=7;
else if(70<=c&&c<80)
j=8;
else if(80<=c&&c<90)
j=9;
else
j=10;
switch(j){
case 1:
gs(a + "+" + b + "=");
break;
case 2:
gs(a + "-" + b + "=");
break;
case 3:
gs(a + "*" + b + "=");
break;
case 4:
gs(a + "/" + b + "=");
break;
}
count++;
}
gs("一共有:"+count+"四则运算题目");
}
public static void jf(int a,int b){
if(a>=b)
gs(a + "-" + b + "=");
else{
gs(b + "-" + a + "=");
}
}
public static void cf(int a,int b){
if(b>0)
gs(a + "/" + b + "=");
else{
b=b+1;
gs(a + "/" + b + "=");
}
}
}
public class P1 {
public static void gs(Object obj){
System.out.println(obj);
}
public static void main(String[] args){
int count = 0;
for(int i=0;i<300;i++){
int a = (int)(Math.random()*100);//随机数
int b = (int)(Math.random()*100);
int c = (int)(Math.random()*100);
int j=1;
if(0<=c&&c<10)
j=1;
else if(10<=c&&c<20)
j=2;
else if(20<=c&&c<30)
j=3;
else if(30<=c&&c<40)
j=4;
else if(40<=c&&c<50)
j=5;
else if(50<=c&&c<60)
j=6;
else if(60<=c&&c<70)
j=7;
else if(70<=c&&c<80)
j=8;
else if(80<=c&&c<90)
j=9;
else
j=10;
switch(j){
case 1:
gs(a + "+" + b + "=");
break;
case 2:
gs(a + "-" + b + "=");
break;
case 3:
gs(a + "*" + b + "=");
break;
case 4:
gs(a + "/" + b + "=");
break;
}
count++;
}
gs("一共有:"+count+"四则运算题目");
}
public static void jf(int a,int b){
if(a>=b)
gs(a + "-" + b + "=");
else{
gs(b + "-" + a + "=");
}
}
public static void cf(int a,int b){
if(b>0)
gs(a + "/" + b + "=");
else{
b=b+1;
gs(a + "/" + b + "=");
}
}
}
![](https://images2015.cnblogs.com/blog/1120585/201703/1120585-20170309142554125-378754042.png)