package sizeyunsuan2; import java.util.*; import java.util.Random; public class enum1 { char x[]={'+','-','*','/'}; int a[][]=new int[1000][100]; int zheng_que=0; int cuo_wu=0; int cuo_ti[]=new int[1000]; int czgs; int t=1; int coc,y,n,kh,fw=100; public static void main(String args[]) { enum1 c= new enum1(); c.enumm(); c.magic(); c.cuo_ti_ben(); } //************************************** void enumm() { Scanner input=new Scanner(System.in); System.out.println("number? "); n=input.nextInt(); System.out.println("Have '*'and'/'?(1 or 0) "); coc=input.nextInt(); if(coc!=0) coc=4; else coc=2; System.out.println("cao zuo ge shu :"); czgs=input.nextInt(); //printf("kuo hao "); //scanf("%d",&kh); kh=0; System.out.println("fan wei :"); fw=input.nextInt(); } //************************** void cuo_ti_ben() { if(cuo_wu!=0) System.out.print(" ***cuo ti*** "); for(int i=0;i<cuo_wu;i++) { System.out.print((i+1)); System.out.print(". "); output(cuo_ti[i]); System.out.print(yun_suan(cuo_ti[i])); System.out.println(); } System.out.print("zheng que lu:"+(double)(n-cuo_wu)/n*100+"%"); } void output(int i) { for(int k=0;k<2*czgs-1;k++) { if(k%2==0) System.out.print(a [i] [k]); else System.out.print(x[ a [i] [k]%coc ]); } System.out.print("="); } int zuoti(int daan,int i) { int daan1; Scanner input=new Scanner(System.in); daan1=input.nextInt(); if(daan1==daan) { System.out.print("***yes*** "); zheng_que++; return 1; } else { System.out.print("***no*** "); cuo_ti[cuo_wu]=i; cuo_wu++; return 0; } } //*********************************** int yun_suan(int i) { int daan=0,w=0; int []b=new int[20]; for(int j=0;j<czgs*2-1;j++) { b[j]=a[i][j]; } for(int k=1;k<czgs*2-2;k+=2) { switch(a[i][k]%coc){ case 2: b[k-1]=a[i][k-1]*a[i][k+1]; for(int j=k;j<czgs*2+2;j++) b[j]=b[j+2]; break; case 3: b[k-1]=a[i][k-1]/a[i][k+1]; for(int j=k;j<czgs*2+2;j++) b[j]=b[j+2]; break; } } daan+=b[0]; for(int k=1;k<czgs*2-2;k+=2) { if(b[k]%coc==0) daan+=b[k+1]; else daan-=b[k+1]; } return daan; } //**************************************** static int chachong(int i,int czgs,int[][] a,int coc) { int same=0; for(int j=0;j<i;j++) { for(int k=0;k<czgs*2-1;k++) { if(a[i][j]==a[i][k]) same++; if(a[i][k+1]==0&&a[i][k]%coc==3&&k%2==1) return 0; } if(same==czgs*2-1) return 0; else return 1; } return 1; } //************************************** void magic() { Random rand1 = new Random(); Random x = new Random(); for(int i=0;i<n;i++) { for(int k=0;k<czgs*2-1;k++) { a[i][k]=rand1.nextInt(fw+1); } t=chachong(i,czgs,a,coc); if(t!=0) { output(i); int daan=yun_suan(i); zuoti(daan,i); } else i--; } } }