3.3.2016 Tangyeye
#include <stdio.h>
#include <iostream>
#include <time.h>
#include <fstream>
#include <ostream>
#include <string>
using namespace Std;
#define MAX N
int a (void)
{
Srand ((unsigned) time (NULL));
int a,b,c,d,e,i,n,x;
int N;
cout<< "Please enter the number of questions! "<<endl;
cin>>i;
cout<< "Please enter the number of arithmetic" <<endl;
cin>>n;
cout<< "Is there a multiplication number? (1 Yes, 0 NO) "<<endl;
cin>>x;
cout<< "The printed arithmetic result is non-negative, and the division operation is empty" <<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,n,x;
int N;
cout<< "Please enter the number of questions! "<<endl;
cin>>i;
cout<< "Please enter the number of arithmetic" <<endl;
cin>>n;
cout<< "Is there a multiplication number? (1 Yes, 0 NO) "<<endl;
cin>>x;
cout<< "The printed arithmetic result is non-negative, and the division operation is empty" <<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;
Char A1;
int N;
cout<< "Please enter the number of participants! (3<=n<10) "<<endl;
cin>>n3;
cout<< "Please enter the number of questions! "<<endl;
cin>>i;
cout<< "Please enter the number of arithmetic" <<endl;
cin>>n;
cout<< "Is there a multiplication number? (1 Yes, 0 NO) "<<endl;
cin>>x;
cout<< "The printed arithmetic result is non-negative, and the division operation is empty" <<endl;
if (x==0)
{
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
}
if (n3=3)
{
C2=rand ()%3+1;
Switch (C2)
{
Case 1:cout<<a<<a1<<b<<endl;
Break
Case 2:cout<< "(" <<a<<a1<<b<< ")" <<b<<endl;
Break
Case 3:cout<<a<< "(" <<a<<a1<<b<< ")" <<endl;
Break
}
}
}}
Else
{
for (int j=0;j<i;j++)
{
}
}
return 0;
}
int main (void)
{
int n,n1,n3;
cout<< "Do you have parentheses?" (1 Yes, 0 NO) "<<endl;
cin>>n1;
if (n1=1)
{
{
Q ();
}
}
if (n1=0)
{
cout<< "Do you want to print? (1 deposit in document, 0 No) "<<endl;
cin>>n;
if (n==1)
{
b ();
}
else if (n==0)
{
A ();
}
Else
{
cout<< "Error input!" <<endl;
}
}
Else
{
cout<< "Error input!" <<endl;
}
}
Arithmetic Enhanced