• 四则运算加强版


    题目要求:

    题目避免重复。

    可制定。(数量/打印方式)。

    可以控制下列参数:
    • 是否有乘除法
    • 是否有括号(最多可支持10个数参与计算)
    • 数值范围
    • 加减有无负数
    • 乘除有无余

    我的实现:
    1.无括号的情况可以正确运行,有括号的情况不符合要求。
    2.打印文件符合要求。
    3.数值的要求符合要求。
    4.在无括号的情况下,可以实现加减无负数,乘除无余数。
    5.递归嵌套循环只能要求括号嵌套到第五层。









    程序分析:

    无括号的情况就加一些限制条件就行,用循环解决。
    有括号的情况:把a1=(一个随机数a+一个随机符号+一个随机数b),作为主要的母体。第二层再用a2=(a1+b) 或者a2=a1 或者是 a2=(a+a1)。
    再第三层a3=(a2+b)或者a3=(a+a2)或者a3=a2.一层一层递归。所以代码比较多还混乱。在规定的时间内只实现第五层一下的括号嵌套。课下一
    定好好完善代码。


    //
    3.12.2016 tangyeye #include<stdio.h> #include<iostream> #include<time.h> #include<fstream> #include<ostream> #include<string> #include<stdlib.h> using namespace std; #define MAX N /*无打印功能的无括号算式*/ int a(void) { srand((unsigned)time(NULL)); int a,b,c,i,x; int N; cout<<"请输入题目的数量!"<<endl; cin>>i; cout<<"请输入多少数以内的四则运算"<<endl; cin>>N; cout<<"是否有乘除号?(1是,0否)"<<endl; cin>>x; cout<<"打印的四则运算结果为非负数,且除法运算无余数"<<endl; if(x==0) { for(int j=0;j<i;j++) { a=rand()%MAX; b=rand()%MAX; c=rand()%2+1; switch(c){ case 1: cout<<a<<"+"<<b<<endl; break; case 2: if(a>=b) {cout<<a<<"-"<<b<<endl;} else{cout<<b<<"-"<<a<<endl;}; break; } }} else { for(int j=0;j<i;j++) { a=rand()%MAX; b=rand()%MAX; c=rand()%4+1; switch(c) { case 1: cout<<a<<"+"<<b<<endl; break; case 2:if(a>=b) {cout<<a<<"-"<<b<<endl;} else{cout<<b<<"-"<<a<<endl;} break; case 3: cout<<a<<"*"<<b<<endl; break; case 4:if(a%b==0) {cout<<a<<"/"<<b<<endl;}else{cout<<a<<"*"<<b<<endl;} break; } } return 0; } } /*有打印功能的无括号算式*/ int b(void) { srand((unsigned)time(NULL)); int a,b,c,d,e,i,x; int N; cout<<"请输入题目的数量!"<<endl; cin>>i; cout<<"请输入多少数以内的四则运算"<<endl; cin>>N; cout<<"是否有乘除号?(1是,0否)"<<endl; cin>>x; cout<<"打印的四则运算结果为非负数,且除法运算无余数"<<endl; ofstream fout("D:\1.txt",ios::binary); if(!fout) { cerr<<"open wrong!"<<endl; } if(x==0) { for(int j=0;j<i;j++) { a=rand()%MAX; b=rand()%MAX; c=rand()%2+1; switch(c){ case 1: fout<<a<<"+"<<b<<endl; break; case 2: if(a>=b) {fout<<a<<"-"<<b<<endl;} else{fout<<b<<"-"<<a<<endl;}; break; } }} else { for(int j=0;j<i;j++) { a=rand()%MAX; b=rand()%MAX; c=rand()%4+1; switch(c) { case 1: fout<<a<<"+"<<b<<endl; break; case 2:if(a>=b) {fout<<a<<"-"<<b<<endl;} else{fout<<b<<"-"<<a<<endl;} break; case 3: fout<<a<<"*"<<b<<endl; break; case 4:if(a%b==0) {fout<<a<<"/"<<b<<endl;}else{fout<<a<<"*"<<b<<endl;} break; } } return 0; } } /*无打印功能的带括号的算式*/ int q(void) { srand((unsigned)time(NULL)); int i,x,a,b,c,d,n3,c2; string a2,a3,a4,a5,a6,a7,a8,a9,a10; char a1,b1[10],c1,d1[10]; char p[10]; char p1[10],p2[10]; int N; cout<<"请输入参与数目!(3<=n<10)"<<endl; cin>>n3; cout<<"请输入题目的数量!"<<endl; cin>>i; cout<<"请输入多少数以内的四则运算"<<endl; cin>>N; cout<<"是否有乘除号?(1是,0否)"<<endl; cin>>x; cout<<"打印的四则运算结果为非负数,且除法运算无余数"<<endl; if(x==0) { c=rand()%2+1; srand((unsigned)time(NULL)); switch(c) { case 1:a1='+'; break; case 2:a1='-'; break; } if(n3==3) { srand((unsigned)time(NULL)); for(int j=0;j<i;j++) { a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a3=a2; break; case 2:a3='('+a2+a1+p2_+')'; break; case 3:a3='('+p2_+a1+a2+')'; break; } cout<<a3<<endl; } } if(n3==4) //44444444444444444 { srand((unsigned)time(NULL)); for(int j=0;j<i;j++) { {a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a3=a2; break; case 2:a3='('+a2+a1+p2_+')'; break; case 3:a3='('+p2_+a1+a2+')'; break; } } a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 3:a4=a3; break; case 2:a4='('+a3+a1+p2_+')'; break; case 1:a4='('+p2_+a1+a3+')'; break; } cout<<a4<<endl; } } if(n3==5) //5555555555555555555 { srand((unsigned)time(NULL)); for(int j=0;j<i;j++) { { { a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a3=a2; break; case 2:a3='('+a2+a1+p2_+')'; break; case 3:a3='('+p2_+a1+a2+')'; break; } } a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 3:a4=a3; break; case 2:a4='('+a3+a1+p2_+')'; break; case 1:a4='('+p2_+a1+a3+')'; break; } } a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a5=a4; break; case 2:a5='('+a4+a1+p2_+')'; break; case 3:a5='('+p2_+a1+a4+')'; break; } cout<<a5<<endl; } } if(n3==6) //666666666666666 { for(int j=0;j<i;j++) { { { { a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a3=a2; break; case 2:a3='('+a2+a1+p2_+')'; break; case 3:a3='('+p2_+a1+a2+')'; break; } } a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 3:a4=a3; break; case 2:a4='('+a3+a1+p2_+')'; break; case 1:a4='('+p2_+a1+a3+')'; break; } } a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a5=a4; break; case 2:a5='('+a4+a1+p2_+')'; break; case 3:a5='('+p2_+a1+a4+')'; break; } } srand((unsigned)time(NULL)); a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a6=a5; break; case 2:a6='('+a5+a1+p_+')'; break; case 3:a6='('+p1_+a1+a5+')'; break; } cout<<a6<<endl; } } if(n3==7) //77777777777777777 { for(int j=0;j<i;j++) { { { { { a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a3=a2; break; case 2:a3='('+a2+a1+p2_+')'; break; case 3:a3='('+p2_+a1+a2+')'; break; } } a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 3:a4=a3; break; case 2:a4='('+a3+a1+p2_+')'; break; case 1:a4='('+p2_+a1+a3+')'; break; } } a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a5=a4; break; case 2:a5='('+a4+a1+p2_+')'; break; case 3:a5='('+p2_+a1+a4+')'; break; } } srand((unsigned)time(NULL)); a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; cout<<a2; c1=rand()%3+1; switch(c1) { case 1:a6=a5; break; case 2:a6='('+a5+a1+p_+')'; break; case 3:a6='('+p1_+a1+a5+')'; } } srand((unsigned)time(NULL)); a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; cout<<a2; c1=rand()%3+1; switch(c1) { case 1:a7=a6; break; case 2:a7='('+a6+a1+p_+')'; break; case 3:a7='('+p1_+a1+a6+')'; } cout<<a7<<endl; } } if(n3==8) //8888888888888 { for(int j=0;j<i;j++) { { { { { { a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a3=a2; break; case 2:a3='('+a2+a1+p2_+')'; break; case 3:a3='('+p2_+a1+a2+')'; break; } } a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 3:a4=a3; break; case 2:a4='('+a3+a1+p2_+')'; break; case 1:a4='('+p2_+a1+a3+')'; break; } } a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a5=a4; break; case 2:a5='('+a4+a1+p2_+')'; break; case 3:a5='('+p2_+a1+a4+')'; break; } } srand((unsigned)time(NULL)); a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; cout<<a2; c1=rand()%3+1; switch(c1) { case 1:a6=a5; break; case 2:a6='('+a5+a1+p_+')'; break; case 3:a6='('+p1_+a1+a5+')'; } } srand((unsigned)time(NULL)); a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; cout<<a2; c1=rand()%3+1; switch(c1) { case 1:a7=a6; break; case 2:a7='('+a6+a1+p_+')'; break; case 3:a7='('+p1_+a1+a6+')'; } } srand((unsigned)time(NULL)); a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; cout<<a2; c1=rand()%3+1; switch(c1) { case 1:a8=a7; break; case 2:a8='('+a7+a1+p_+')'; break; case 3:a8='('+p1_+a1+a7+')'; } cout<<a8<<endl; } } if(n3==9) //9999999 { for(int j=0;j<i;j++) { { { { { { { a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a3=a2; break; case 2:a3='('+a2+a1+p2_+')'; break; case 3:a3='('+p2_+a1+a2+')'; break; } } a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 3:a4=a3; break; case 2:a4='('+a3+a1+p2_+')'; break; case 1:a4='('+p2_+a1+a3+')'; break; } } a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a5=a4; break; case 2:a5='('+a4+a1+p2_+')'; break; case 3:a5='('+p2_+a1+a4+')'; break; } } srand((unsigned)time(NULL)); a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a6=a5; break; case 2:a6='('+a5+a1+p_+')'; break; case 3:a6='('+p1_+a1+a5+')'; } } srand((unsigned)time(NULL)); a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a7=a6; break; case 2:a7='('+a6+a1+p_+')'; break; case 3:a7='('+p1_+a1+a6+')'; } } srand((unsigned)time(NULL)); a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; c1=rand()%3+1; switch(c1) { case 1:a8=a7; break; case 2:a8='('+a7+a1+p_+')'; break; case 3:a8='('+p1_+a1+a7+')'; } } srand((unsigned)time(NULL)); a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; itoa(a,p2,10); string p2_=p2; itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; cout<<a2; c1=rand()%3+1; switch(c1) { case 1:a9=a8; break; case 2:a9='('+a8+a1+p_+')'; break; case 3:a9='('+p1_+a1+a8+')'; } cout<<a9<<endl; } } } else { a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; c=rand()%4+1; switch(c) { case 1:a1='+'; break; case 2:a1='-'; break; case 3:a1='*'; break; case 4:a1='/'; break; } itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; cout<<a2; if(n3==3) { for(int j=0;j<=i;j++) { c1=rand()%3+1; switch(c1) { case 1:a3=a2; break; case 2:a3='('+a2+a1+p_+')'; break; case 3:a3='('+p1_+a1+a2+')'; break; }} cout<<a3<<endl; } if(n3==4) { for(int j=0;j<=i;j++) { c1=rand()%3+1; switch(c1) { case 1:a4=a3; break; case 2:a4='('+a3+a1+p_+')'; break; case 3:a4='('+p1_+a1+a3+')'; break; }} cout<<a4<<endl; } if(n3==5) { for(int j=0;j<=i;j++) { c1=rand()%3+1; switch(c1) { case 1:a5=a4; break; case 2:a5='('+a4+a1+p_+')'; break; case 3:a5='('+p1_+a1+a4+')'; }} cout<<a5<<endl; } if(n3==6) { for(int j=0;j<=i;j++) { c1=rand()%3+1; switch(c1) { case 1:a6=a5; break; case 2:a6='('+a5+a1+p_+')'; break; case 3:a6='('+p1_+a1+a5+')'; }} cout<<a6<<endl; } if(n3==7) { for(int j=0;j<=i;j++) { c1=rand()%3+1; switch(c1) { case 1:a7=a6; break; case 2:a7='('+a6+a1+p_+')'; break; case 3:a7='('+p1_+a1+a6+')'; } } cout<<a7<<endl; } if(n3==8) { for(int j=0;j<=i;j++) { c1=rand()%3+1; switch(c1) { case 1:a8=a7; break; case 2:a8='('+a7+a1+p_+')'; break; case 3:a8='('+p1_+a1+a7+')'; }} cout<<a8<<endl; } if(n3==9) { for(int j=0;j<=i;j++) { c1=rand()%3+1; switch(c1) { case 1:a9=a8; break; case 2:a9='('+a8+a1+p_+')'; break; case 3:a9='('+p1_+a1+a8+')'; } } cout<<a9<<endl; } } return 0; } /*有打印功能的带括号算式*/ int p(void) { srand((unsigned)time(NULL)); int i,x,a,b,c,d,n3,c2; string a2,a3,a4,a5,a6,a7,a8,a9,a10; char a1,b1[10],c1,d1[10]; char p[10]; char p1[10]; int N; cout<<"请输入参与数目!(3<=n<10)"<<endl; cin>>n3; cout<<"请输入题目的数量!"<<endl; cin>>i; cout<<"请输入多少数以内的四则运算"<<endl; cin>>N; cout<<"是否有乘除号?(1是,0否)"<<endl; cin>>x; cout<<"打印的四则运算结果为非负数,且除法运算无余数"<<endl; ofstream fout("D:\1.txt",ios::binary); if(!fout) { cerr<<"open wrong!"<<endl; } if(x==0) { for(int j=0;j<i;j++) { a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; c=rand()%2+1; switch(c) { case 1:a1='+'; break; case 2:a1='-'; break; } itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; fout<<a2; if(n3=3) { c1=rand()%3+1; switch(c1) { case 1:a3=a2; break; case 2:a3='('+a2+a1+p_+')'; break; case 3:a3='('+p1_+a1+a2+')'; } fout<<a3<<endl; } if(n3=4) { c1=rand()%3+1; switch(c1) { case 1:a4=a3; break; case 2:a4='('+a3+a1+p_+')'; break; case 3:a4='('+p1_+a1+a3+')'; } fout<<a4<<endl; } if(n3=5) { c1=rand()%3+1; switch(c1) { case 1:a5=a4; break; case 2:a5='('+a4+a1+p_+')'; break; case 3:a5='('+p1_+a1+a4+')'; } fout<<a5<<endl; } if(n3=6) { c1=rand()%3+1; switch(c1) { case 1:a6=a5; break; case 2:a6='('+a5+a1+p_+')'; break; case 3:a6='('+p1_+a1+a5+')'; } fout<<a6<<endl; } if(n3=7) { c1=rand()%3+1; switch(c1) { case 1:a7=a6; break; case 2:a7='('+a6+a1+p_+')'; break; case 3:a7='('+p1_+a1+a6+')'; } fout<<a7<<endl; } if(n3=8) { c1=rand()%3+1; switch(c1) { case 1:a8=a7; break; case 2:a8='('+a7+a1+p_+')'; break; case 3:a8='('+p1_+a1+a7+')'; } fout<<a8<<endl; } if(n3=9) { c1=rand()%3+1; switch(c1) { case 1:a9=a8; break; case 2:a9='('+a8+a1+p_+')'; break; case 3:a9='('+p1_+a1+a8+')'; } fout<<a9<<endl; } } } else { for(int j=0;j<i;j++) { a=rand()%MAX; b=rand()%MAX; d=rand()%MAX; c=rand()%4+1; switch(c) { case 1:a1='+'; break; case 2:a1='-'; break; case 3:a1='*'; break; case 4:a1='/'; break; } itoa(b,p,10); string p_=p; itoa(d,p1,10); string p1_=p1; a2='('+p_+a1+p1_+')'; fout<<a2; if(n3=3) { c1=rand()%3+1; switch(c1) { case 1:a3=a2; break; case 2:a3='('+a2+a1+p_+')'; break; case 3:a3='('+p1_+a1+a2+')'; } fout<<a3<<endl; } if(n3=4) { c1=rand()%3+1; switch(c1) { case 1:a4=a3; break; case 2:a4='('+a3+a1+p_+')'; break; case 3:a3='('+p1_+a1+a3+')'; } fout<<a4<<endl; } if(n3=5) { c1=rand()%3+1; switch(c1) { case 1:a5=a4; break; case 2:a5='('+a4+a1+p_+')'; break; case 3:a5='('+p1_+a1+a4+')'; } fout<<a5<<endl; } if(n3=6) { c1=rand()%3+1; switch(c1) { case 1:a6=a5; break; case 2:a6='('+a5+a1+p_+')'; break; case 3:a6='('+p1_+a1+a5+')'; } fout<<a6<<endl; } if(n3=7) { c1=rand()%3+1; switch(c1) { case 1:a7=a6; break; case 2:a7='('+a6+a1+p_+')'; break; case 3:a7='('+p1_+a1+a6+')'; } fout<<a7<<endl; } if(n3=8) { c1=rand()%3+1; switch(c1) { case 1:a8=a7; break; case 2:a8='('+a7+a1+p_+')'; break; case 3:a8='('+p1_+a1+a7+')'; } fout<<a8<<endl; } if(n3=9) { c1=rand()%3+1; switch(c1) { case 1:a9=a8; break; case 2:a9='('+a8+a1+p_+')'; break; case 3:a9='('+p1_+a1+a8+')'; } fout<<a9<<endl; } } } return 0; } int main(void) { int n,n1; cout<<"是否有括号?(1有,0否)"<<endl; cin>>n1; if(n1==1) { cout<<"是否打印?(1存入文档,0否)"<<endl; cin>>n; if(n==0) { q(); } if(n==1) { p(); } } if(n1==0) { cout<<"是否打印?(1存入文档,0否)"<<endl; cin>>n; if(n==1) { b(); } if(n==0) { a(); } } }
  • 相关阅读:
    🏆【Java技术专区】「编译器专题」彻底你明白什么是JIT编译器(Just In Time编译器)
    Sql server日期函数用法
    Oracle 11g密码过期问题及解决方案
    该驱动程序不支持 SQL Server 8 版
    maven添加sqlserver的jdbc驱动包
    com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 ‘DUAL‘ 无效 | Druid双数据源MySQL+SQL server
    用Java连接SQL Server2000数据库的两种方法与jDTS
    无法远程连接Sql Server 2000解决方案
    为 SQL Server 2000 数据库添加用户名和密码
    Oracle的number数据类型
  • 原文地址:https://www.cnblogs.com/tyyhph/p/5268157.html
Copyright © 2020-2023  润新知