标签:简单 new for bool ack 软件 pack public switch
这周敲了一个简单的输出四则算法的粗糙软件,可以实现不重复输出,乘法实现验证结果不超过100,除法除数不为0,减法不能为负,可以自由选择输出多少道题,每行输出多少个。
下面是源码:
package first;
import java.util.Scanner;
import java.util.Random;
public class one{
static Scanner sc = new Scanner(System.in);
public static void main(String[] args){
int num1, num2, num3; int b;
int aaa[][]=new int[100000][3];
char c=‘ ‘;
int num_end;
int length;
boolean jud=false;
System.out.println("请选择生产多少道题:");
num_end=sc.nextInt();
System.out.println("请输入每行输出几道题:");
length=sc.nextInt();
for(int i=0;i<num_end;){
Random a=new Random();
num1=a.nextInt(101);
num2=a.nextInt(101);
num3=a.nextInt(101);
b=num3%4;
switch(b){
case 0:
c=‘+‘;
break;
case 1:
c=‘-‘;
break;
case 2:
c=‘*‘;
break;
case 3:
c=‘/‘;
break;
}
if(b==3&&num2==0){
continue;
}
if(b==2&&(num1*num2)>100){
continue;
}
if(b==3&&(num1%num2)!=0){
continue;
}
else{ jud=true;
}
for(int u=0;u<100000;u++){
int a1=0,a2=0,a3=0;
a1=aaa[i][0];
a2=aaa[i][1];
a3=aaa[i][2];
if(a1==num1&&a2==num2&&a3==b){
jud=false;
}
}
if(jud){
System.out.print("这是第");
System.out.print(i);
System.out.print("道题");
System.out.print(num1);
System.out.print(c);
System.out.print(num2);
System.out.print("=");
i++;
}
if(i<100000){
aaa[i][0]=num1;
aaa[i][1]=num2;
aaa[i][2]=b;
}
if(i%length==0)
System.out.println();
}
}
}
标签:简单 new for bool ack 软件 pack public switch
原文地址:https://www.cnblogs.com/studya/p/11529845.html