I. Topic requirements
Produce 300 primary school second grade of arithmetic mathematics problem, subtraction cannot appear negative numbers, division to divide evenly.
Two. Writing process
Write a math problem that produces 30 arithmetic of primary school sophomore, with Rand () generating random numbers, and random symbols, in the division operation in the case of the divisor is not zero by using a set of random numbers to generate dividend and divisor is the divisor of the integer multiples, so as to ensure division, subtraction to determine the size of two random numbers, The result of the output is a large number minus a decimal. Then use the For loop 30 times to output a 30-way problem.
Three. Program operation
Four. Program code
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void Main ()
{
int A, B, C, D, E, I, J;
Srand (Time (NULL));
printf ("Arithmetic in the second year of primary school \ n");
for (i = 0; i <; i++)
{
A = rand ()% 100;
b = rand ()% 100;
c = rand ()% 4;
Switch (c)
{
Case 0:
printf ("%d+%d=\n", A, b);
Break
Case 1:
if (a < b)
{
printf ("%d-%d=\n", B, a);
}
Else
printf ("%d-%d=\n", A, b);
Break
Case 2:
printf ("%d*%d=\n", A, b);
Break
Case 3:
{
d = rand ()% 20;
if (d! = 0)
e = rand ()% 4;
Switch (e)
{
Case 0:
printf ("0÷%d=\n", D);
Break
Case 1:
printf ("%d÷%d=\n", D, D);
Break
Case 2:
j = 2 * D;
printf ("%d÷%d=\n", J, D);
Break
Case 3:
j = 3 * D;
printf ("%d÷%d=\n", J, D);
Break
}
Break
}
}
}
System ("pause");
}
Arithmetic problems in the second grade of primary school