//这个代码吧 略有缺陷 四则运算的乘除与加减 只能从左到右依次计算 还没想好怎么做
import java.util.Random;
import java.util.Scanner;
public class test {
public static void main(String[] args) {
String []cun =new String[10000];
double []daan =new double [1000];
double [ ]shuru = new double [1000];
String []cuotiji = new String[1000];
double []cuotidaan = new double[1000];
int zhengquegeshu=0;
int cuogeshu=0;
double zhengquelv;
String[] cunfuhao = new String[10000];
Random random = new Random();
int cout=0;//记个数
Scanner sc = new Scanner(System.in);
System.out.println("请输入需要的题目数量:");
int n = sc.nextInt();
System.out.println("请输入操作数的个数");
int m = sc.nextInt();
System.out.println("请输入取值范围");
int max = sc.nextInt();
int min = sc.nextInt();
for (int i = 0; i < n; i++) {//出题个数
char a ='+';
int j;
for (j = 0; j < m; j++) {//操作数的个数
double s = shuzi(max, min);
if(j==0){
daan[i]= s;
}
else {
switch (a){
case '+':{
daan[i]+=s;
break;
}
case '-':{
daan[i]-=s;
break;
}
case '*':{
daan[i]*=s;
break;
}
case '/':{
daan[i]/=s;
}
default:break;
}
}
if (j == m - 1) {
System.out.println("=");
a = '=';
}
else {
a = caozuofu();
}
if(j==0) {
cun[i] = "" + s + a;
cout++;
}
else{
cun[i] += "" + s + a;
cout++;
}//存储完毕
}
System.out.println("请输入你的答案");
shuru[i]= sc.nextDouble();
//cheak(cun,x,cout);//查重
}
for (int i = 0; i < n; i++) {
if(shuru[i]==daan[i]){
zhengquegeshu++;
}
else {
cuotiji[cuogeshu]= cun [i];
cuotidaan[cuogeshu]= daan[i];
cuogeshu++;
}
}
zhengquelv = zhengquegeshu*1.00 / n*100;
System.out.println("您的正确率为"+zhengquelv+"%");
System.out.println("您的错题有:");
for (int i = 0; i < cuogeshu; i++) {
System.out.println(cuotiji[i]);
}
System.out.println("是否重做错题 1.是 2.否");
int panduan= sc.nextInt();
if(panduan == 1){
for (int i = 0; i < cuogeshu; i++) {
System.out.println(cuotiji[i]);
double key = sc.nextDouble();
if(key ==cuotidaan[i]){
System.out.println("做对了");
}
else{
System.out.println("又做错了");
}
}
}
}
public static double shuzi(int max ,int min){//生成四则运算的数字
Random random = new Random();
double number = random.nextInt(max-min) + min;
System.out.print(number);
return number;
}
public static char caozuofu(){//生成操作符
Random random = new Random();
char a='0' ;
int mark = random.nextInt(4);
switch (mark) {
case 0: {
System.out.print("+");
a='+';
break;
}
case 1: {
System.out.print("-");
a='-';
break;
}
case 2: {
System.out.print("*");
a='*';
break;
}
case 3: {
System.out.print("/");
a='/';
break;
}
}
return a;
}
/*public static void cheak(String [][]cun, String []x,int cout){
int flag = 0;
if(cout==0){
System.out.println("错误");
}
for (int i = 0; i < cout; i++) {
if(x.equals(cun[i])){
flag =1;
}
}
if(flag==0) {
System.out.println("重复");
}
}*/
}