Automatically generate four arithmetic applets for primary school students and four arithmetic applets
Question requirements:
Write a program that can automatically generate the four arithmetic questions of primary school. After preliminary drafting of the functions to be implemented, estimate how long it will take. During programming, record how long it actually took.
C language source code:
# Include <stdio. h>
# Include <stdlib. h>
Main ()
{
Int n, a, B, c, d, e, f, g, h;
Printf ("[----------- Main Menu -----------] \ n ");
Printf ("---------- 1. Addition calculation question --------- \ n ");
Printf ("---------- 2. subtraction calculation question --------- \ n ");
Printf ("---------- 3. multiplication calculation question --------- \ n ");
Printf ("---------- 4. Division calculation question --------- \ n ");
Printf ("---------- 0. Exit program --------- \ n ");
Printf ("select :");
Scanf ("% d", & n );
Switch (n)
{
Case 1:
{
A = rand () % 100 + 1;
B = rand () % 100 + 1;
Printf ("% d + % d = \ n", a, B );
Break;
}
Case 2:
{
C = rand () % 100 + 1;
D = rand () % 100 + 1;
Printf ("% d-% d = \ n", c, d );
Break;
}
Case 3:
{
E = rand () % 100 + 1;
F = rand () % 100 + 1;
Printf ("% d * % d = \ n", e, f );
Break;
}
Case 4:
{
G = rand () % 100 + 1;
H = rand () % 100 + 1;
Printf ("% d/% d = \ n", g, h );
Break;
}
}
}
Summary:
I used the classroom time to complete this small program. In addition to the time explained by the teacher and the time of class, there were 10 minutes left. This is an original blog post. Although its technical content is low, it is also a new way of learning, a new beginning, and difficulties are constantly found in the programming process, the final process of solving the difficulties is the most wonderful moment for our programmers.