Requirements for new addition:
1. The number of topics can be specified;
2. Supports true fractional operations.
Code writing:
#include <stdio.h>
#include <Windows.h>
#include <time.h>
void Main ()
{
int A, B, C, d,i,m,n;
float p, q;
Srand (Unsigned (Time (NULL)));
for (i = 0; i <; i++)
{
A = rand ()% 100;
b = rand ()% 100;
c = rand ()% 5;
Switch (c)
{
Case 0:printf ("%d +%d =\n", A, b);
Break
Case 1:if (A < b)
{
D = A;
A = b;
b = D;
}
printf ("%d-%d =\n", A, b);
Break
Case 2:printf ("%d *%d =\n", A, b);
Break
Case 3:
while (b = = 0)
{
b = rand ()% 100;
}
printf ("%d/%d =\n", A, b);
Break
Case 4:
A = rand ()% 100;
b = rand ()% 100;
m = rand ()% 100;
n = rand ()% 100;
c = rand ()%4;
while (b = = 0)
{
b = rand ()% 100;
}
while (n = = 0)
{
n = rand ()% 100;
}
if (a > B)
{
D = A;
A = b;
b = D;
}
if (M > N)
{
d = m;
m = n;
n = d;
}
Switch (c)
{
Case 0:printf ("%d/%d +%d/%d =\n", A, B, M, n);
Break
Case 1:
p = (float) A/(float) b;
Q = (float) m/(float) n;
if (P < q)
{
D = A;
A = m;
m = D;
D = b;
b = n;
n = d;
}
printf ("%d/%d-%d/%d =\n", a,b,m,n);
Break
Case 2:printf ("%d/%d *%d/%d =\n", A, B, M, n);
Break
Case 3:
A = rand ()% 100;
b = rand ()% 100;
m = rand ()% 100;
n = rand ()% 100;
c = rand ()% 4;
while (M = = 0)
{
m = rand ()% 100;
}
printf ("%d/%d/%d/%d =\n", A, B, M, n);
Break
}
}
}
System ("pause");
}
Operation Result:
Second grade arithmetic extension, can specify the number of topics, and can support the operation of true fractions