//产生随机的四则运算题目,输入答案,判断正误
import java.util.*;
import java.io.*;
class suanshi{ //产生随机数//
Random rand=new Random();
//int a=(int)Math.random()*50;
//int b=(int)Math.random()*20;
//int c=(int)Math.random()*10+1;
//rand.setSeed(long d);
int a=(int)rand.nextInt()/1000000;
int b=(int)rand.nextInt()/1000000;
int c=(int)(rand.nextFloat()*10+1);
int sum=0;
public suanshi(){}
public suanshi(int k){ //产生运算符号//
char d;
if(1<=c&&c<=3){
d='+';
sum=a+b;
}
else
if(4<=c&&c<=6){
d='-';
sum=a-d;
}
else
if(7<=c&&c<=8){
d='×';
sum=a*b;
}
else {
d='÷';
sum=a/b;
}
System.out.print("("+a+")"+"\t"+d+"\t"+"("+b+")"+"=");
//System.out.print(""a+d+b+"=");
}
}
class panduan extends suanshi {
int result;
panduan(){super (1);}
public int flag=0;
panduan(int i){
// if(i==sum) {
if(i==(a+b)) {
System.out.println("你答对了");
flag=1;
}
else {
System.out.println("你答错了"+"\n"+"不要放弃"+"\t");
flag=0;
}
}
int f0(){
flag=0;
return flag;
}
int f1(){
flag=1;
return flag;
}
}
//主类开始//
public class ceshi extends panduan{
public int i=0;
String s="";
ceshi(){
try{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
s=in.readLine();
i=Integer.parseInt(s);
}catch(IOException e){}
panduan p=new panduan(i);
}
//int fc(){return i;}
public static void main(String [] args) {
int j=0;
int tt=0;
String ss="";
System.out.println("这是四则运算题!");
System.out.println("***************");
do{
ceshi t=new ceshi();
//int pp=t.fc();
// t.panduan(pp);
System.out.println("输入0继续.输入1推出");
try{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
ss=in.readLine();
j=Integer.parseInt(ss);
}catch(IOException e){}
switch(j){
case 0:
tt=t.f0();
System.out.println("请继续下一题");break;
case 1:
tt=t.f1();
System.out.println("谢谢使用,再见!");break;
}
}while(tt==0);
}
}
//为什么计算结果不对的 ?