在网上搜索有所借鉴
package team1;
import java.lang.Math;
import java.util.Random;
import java.util.Scanner;
public class Check {
public static int a=new Random().nextInt(100);
public static int b[][]=new int[100][2];
public static int c[]=new int[100];
static Scanner d=null;
public static void main(String[] args) {
int oneNum = (int)(1 + Math.random()*99);
int twoNum = 1 + (int)(Math.random()*99);
int thrNum = 1 + (int)(Math.random()*4);
d =new Scanner(System.in);
System.out.println("请输入题目总数量:");
int n=d.nextInt();
System.out.println("请输入一行的题目数量:");
for(int i = 1;i <=n;i++)
{
b[i][0]=oneNum;
b[i][1]=thrNum;
c[i]=twoNum;
for(int j=0;j<i;j++)
{
if(b[j][0]==oneNum&&b[j][1]==thrNum&&c[j]==twoNum)
{
a=new Random().nextInt(100);
}
}
System.out.println(i);
if(thrNum == 1)
{
System.out.println(oneNum + "+" + twoNum + "=");
}
if(thrNum == 2)
{
if(oneNum>=twoNum)
{System.out.println(oneNum + "-" + twoNum + "=");}
else
{
int T;
T=twoNum;
twoNum=oneNum;
oneNum=T;
System.out.println(oneNum + "-" + twoNum + "=");
}
}
if(thrNum == 3)
{
int A=oneNum *twoNum;
if(A>100)
{ a=new Random().nextInt(100);
System.out.println(oneNum + "*" + twoNum +"=");
}
else
System.out.println(oneNum + "*" + twoNum +"=");
}
if(thrNum == 4)
{
int B=oneNum%twoNum;
if(B!=0&&twoNum==0)
{
a=new Random().nextInt(100);
System.out.println(oneNum + "/" + twoNum + "=");
}
else{
if(twoNum != 0)
{
System.out.println(oneNum + "/" + twoNum + "=");
}
else if(oneNum != 0)
{
System.out.println(oneNum + "/" + twoNum + "=");
}
else
{
System.out.println(30 + "/" + 15 + "=?");
}
}
}
}
}
}
import java.util.Random;
import java.util.Scanner;
public class Check {
public static int a=new Random().nextInt(100);
public static int b[][]=new int[100][2];
public static int c[]=new int[100];
static Scanner d=null;
public static void main(String[] args) {
int oneNum = (int)(1 + Math.random()*99);
int twoNum = 1 + (int)(Math.random()*99);
int thrNum = 1 + (int)(Math.random()*4);
d =new Scanner(System.in);
System.out.println("请输入题目总数量:");
int n=d.nextInt();
System.out.println("请输入一行的题目数量:");
for(int i = 1;i <=n;i++)
{
b[i][0]=oneNum;
b[i][1]=thrNum;
c[i]=twoNum;
for(int j=0;j<i;j++)
{
if(b[j][0]==oneNum&&b[j][1]==thrNum&&c[j]==twoNum)
{
a=new Random().nextInt(100);
}
}
System.out.println(i);
if(thrNum == 1)
{
System.out.println(oneNum + "+" + twoNum + "=");
}
if(thrNum == 2)
{
if(oneNum>=twoNum)
{System.out.println(oneNum + "-" + twoNum + "=");}
else
{
int T;
T=twoNum;
twoNum=oneNum;
oneNum=T;
System.out.println(oneNum + "-" + twoNum + "=");
}
}
if(thrNum == 3)
{
int A=oneNum *twoNum;
if(A>100)
{ a=new Random().nextInt(100);
System.out.println(oneNum + "*" + twoNum +"=");
}
else
System.out.println(oneNum + "*" + twoNum +"=");
}
if(thrNum == 4)
{
int B=oneNum%twoNum;
if(B!=0&&twoNum==0)
{
a=new Random().nextInt(100);
System.out.println(oneNum + "/" + twoNum + "=");
}
else{
if(twoNum != 0)
{
System.out.println(oneNum + "/" + twoNum + "=");
}
else if(oneNum != 0)
{
System.out.println(oneNum + "/" + twoNum + "=");
}
else
{
System.out.println(30 + "/" + 15 + "=?");
}
}
}
}
}
}