Title: Write a program that can automatically generate primary arithmetic.
Analysis: First draw a good flowchart on paper, there is a basic idea, constitute a framework, and then programming on the computer.
Using the auto-Generate function rand () generates three random numbers, including two operands, and a number representing the operation symbol.
0 represents addition, 1 represents subtraction, and 2 represents multiplication. 3 represents division.
Then the switch statement is used to realize the random appearance of the arithmetic symbol.
The code is as follows:
#include <iostream.h>
#include <stdlib.h>
void Main ()
{
int a,b,c;
for (int i=0;i<30;i++)
{
A=rand ()%100;
B=rand ()%100;
C=rand ()%4;
Switch (c)
{
Case 0:
cout<<a<< "+" <<b<< "=" <<endl;break;
Case 1:
cout<<a<< "-" <<b<< "=" <<endl;break;
Case 2:
cout<<a<< "*" <<b<< "=" <<endl;break;
Case 3:
if (b==0)
Break
Else
cout<<a<< "/" <<b<< "=" <<endl;break;
}
}
}
Operation Result:
In the short time of the class, oneself did not complete this procedure, the main reason or oneself Foundation is not firm, many basic knowledge have forgotten, at the beginning also did not learn. In the following days, to check the gaps, and try to make up for their shortcomings.
The first program of software engineering