packagesz;//import java.io.BufferedReader;
importjava.io.File;//import java.io.FileInputStream;
importjava.io.FileOutputStream;importjava.io.IOException;//import java.io.InputStreamReader;
importjava.io.OutputStreamWriter;importjava.util.Iterator;importjava.util.Vector;public classSizezt {//出现运算项的最高个数
private static final int SXSIZE=4;//出多少道题目
private static final int TIMES=100;private static Vector ve=new Vector();public static VectorgetVe() {returnve;
}public static void setVe(Vectorve) {
Sizezt.ve=ve;
}public static VectorgetSe() {returnse;
}public static void setSe(Vectorse) {
Sizezt.se=se;
}private static Vector se=new Vector();public static voidrun() {//TODO 自动生成的方法存根
ve.clear();
se.clear();int times=(int)(Math.random()*(SXSIZE-1)+1);
String szM[]=new String[]{"+","-","X","/"};int numa=0,numb=0,numc=0,numg=0;
String se_c="";int type=0;for(int j=0;j
{boolean g_ok=false;boolean g_run=false;boolean g_list=false;boolean g_xiuzheng=false;
numg=0;
se_c="";for(int i=0;i
{if(g_ok&&isOk(numa)||g_ok&&isOk(numc))
{
se_c+="=";
System.out.print("="+"\n");
ve.add(numc);
numc=-2000;break;
}if(!g_ok)
{
numa=(int)(Math.random()*600+1);
numb=(int)(Math.random()*600+1);if(numg==0)
numg=numa;
}
type=!g_list?(int)(Math.random()*4+1):(int)(Math.random()*2+1);//System.out.print("\t"+type+"\t");
if(type==4)
{if(!g_ok)
{while(numa%numb!=0||numb==1)
{
numa=(int)(Math.random()*600+1);
numb=(int)(Math.random()*600+1);
}
numc=numa/numb;
}else{while(numg%numb!=0)
{
numb=(int)(Math.random()*600+1);
}
numc-=g_xiuzheng?-numg:numg;if(!g_xiuzheng)
numc+=numg/numb;else numc-=numg/numb;
}
g_list=true;
g_run=!g_run;
}else if(type==3)
{if(!g_ok)
{while(numa*numb>1000||numa==1||numb==1)
{
numa=(int)(Math.random()*600+1);
numb=(int)(Math.random()*600+1);
}
numc=numa*numb;
}else{while(numg*numb>1000||numb!=1)
{
numb=(int)(Math.random()*600+1);
}
numc-=g_xiuzheng?numg:numg;
numc+=numg*numb;
}
g_list=true;
}else if(type==2)
{if(!g_ok)
numc=numa-numb;else numc-=numb;
g_list=false;
}else if(type==1)
{if(!g_ok)
numc=numa+numb;else numc+=numb;
g_list=false;
}if(!g_ok)
{
System.out.print(numa+szM[type-1]+numb);
se_c+=numa+szM[type-1]+numb;
}else{
System.out.print(szM[(type==4&&!g_run)?(int)(Math.random()*2):type-1]+numb);
se_c+=szM[(type==4&&!g_run)?(int)(Math.random()*2):type-1]+numb;
}
g_ok=true;if(type==2)
g_xiuzheng=true;else g_xiuzheng=false;
numg=numb;
numb=(int)(Math.random()*600+1);
}if(numc!=-2000)
{
ve.add(numc);
System.out.print("="+"\r\n");
se_c+="=";
}
se.add(se_c);
numc=0;
times=(int)(Math.random()*(SXSIZE-1)+1);
}//Document document = null;//try {//document = XmlUtils.getDocument();//} catch (DocumentException e) {// //TODO 自动生成的 catch 块//e.printStackTrace();//}//Element root = document.getRootElement();//Element user_node = root.addElement("sz");//创建user结点,并挂到root//
// //user_node.setAttributeValue("ve", ve);
}public static boolean isOk(intnum)
{if(num==1||num<=0||num==2)return false;for(int i=2;i<=Math.sqrt(num);i++)
{if(num%i==0)return false;
}return true;
}public void daochu() throwsIOException
{
String st="";int an=0;
Iteratorit;
Iteratorit1;
File a=new File("timu.txt");
FileOutputStream b= newFileOutputStream(a);
OutputStreamWriter c=new OutputStreamWriter(b,"UTF-8");
it=se.iterator();
it1=ve.iterator();int i=0;while(it.hasNext())
{
i++;if(i!=1)
c.append("\r\n");
st=it.next();
an=it1.next();
c.append(st+an+"*");
}
c.close();
b.close();
}public static voidmain(String args[])
{
Sizezt.run();
Sizezt a=newSizezt();try{
a.daochu();
}catch(IOException e) {//TODO 自动生成的 catch 块
e.printStackTrace();
}
Daoru b=newDaoru();try{
b.daoru();
}catch(IOException e) {//TODO 自动生成的 catch 块
e.printStackTrace();
}
}
}