Design ideas:
1. Randomly generate two random numbers using random number method
1.1 Control random number within 100
1.2 Random number is not equal to 0
2. Problems with operators
1.1 The 1,2,3,4 obtained by using redundancy means "+", "-", "*", "/", respectively.
3. How to express a true score
1.1 using random number method to generate two random numbers
1.2 Compare the size of the generated random number, small as the numerator, large as the denominator, get the true fraction
4, the output operation results, with 1, 2 for the integer operation and a true fraction of the operation of the participation
When there is a real score involved, is to a certain extent random, not completely random, need to be improved
Code:
#include <iostream>
using namespace Std;
int main ()
{
int a,b,c,d,e; Define several shaping variables
for (int i=0;i<30;i++)
{
A=1+rand ()%100; Generate random numbers
B=1+rand ()%100;
C=1+rand ()%100;
D=1+rand ()%4;
E=rand ()%2;
if (e==0)//When e=0, it is an integer arithmetic
{
Switch (d)
{
Case 1:
cout<<a<< "+" <<b<< "=" <<endl;
Break
Case 2:
cout<<a<< "-" <<b<< "=" <<endl;
Break
Case 3:
cout<<a<< "*" <<b<< "=" <<endl;
Break
Case 4:
cout<<a<< "/" <<b<< "=" <<endl;
Break
}
}
else (e==1); When E=1, the real score is the arithmetic of participation.
{
if (c>a)
Switch (d)
{
Case 1:
cout<< "(" <<a<< "/" <<c<< ")" << "+" <<b<< "=" <<endl;
Break
Case 2:
cout<< "(" <<a<< "/" <<c<< ")" << "-" <<b<< "=" <<endl;
Break
Case 3:
cout<< "(" <<a<< "/" <<c<< ")" << "*" <<b<< "=" <<endl;
Break
Case 4:
cout<< "(" <<a<< "/" <<c<< ")" << "/" <<b<< "=" <<endl;
Break
}
}
}
return 0;
}
Randomly generate arithmetic questions within 100 of 30-way