Title: Arithmetic of random numbers
Idea: Take two random integers, put the operation symbol in an array, then take a random number, divide by 4, and select the budget symbol by the remainder. The arithmetic of a true fraction is to take four random integers, and to determine the size, the denominator of the true fraction is greater than its numerator.
Code:
#include <iostream>
#include <time.h>
using namespace Std;
void Main ()
{
Srand (Time (NULL));
for (int i = 1; i <=; i++)
{
int a = rand ()%25+1;
int b = rand ()%25+1;
int c = rand ()% 25 + 1;
int d = rand ()% 25 + 1;
int e = a% 2;
int f = b% 4;
int x[4] = {' + ', '-', ' * ', '/'};
int y = 0;
if (e = = 1 && b < a&&d < C)
{
if (f = = 1)
cout << b << '/' << a << ' << ' + ' << ' << d << '/' << C << "=" << Endl;
else if (f = = 2)
cout << b << '/' << a << ' << '-' << ' << d << '/' << C << "=" << Endl;
else if (f = = 3)
cout << b << '/' << a << ' << ' * ' << ' << d << '/' << C << "=" << Endl;
Else
cout << b << '/' << a << ' << '/' << ' << d << '/' << C << "=" << Endl;
}
Else
{
if (f = = 1)
{
y = a + b;
cout << a << ' + ' << b << "=" << Endl;
}
else if (f = = 2)
{
y = a-B;
cout << a << '-' << b << ' = ' << Endl;
}
else if (f = = 3)
{
y = a * b;
cout << a << ' * ' << b << "=" << Endl;
}
Else
{
y = b/a;
cout << b << '/' << a << ' = ' << Endl;
}
}
}
}
Feel: Through this little test, I understand the importance of the idea of "decomposition".
Classroom Test Small Program