This time the programming gave me a big harvest let me know a lot of my shortcomings, so I enjoy the programming process. This exercise gave me a deeper understanding of the C + + language and I will continue to work hard to learn the language.
In just programming a lot of language format forgotten, after the book review after the idea of programming to write a program. After the end of the program there are a lot of mistakes, let me realize that I have a lot of shortcomings. After careful examination of the excluded errors, the pride after programming is very strong, although this program is not difficult. This time the programming my harvest is still very big.
The program I have written is for students in grades 2 and 3. The code is simple and the interface is simple and easy to use. Users only need to follow the instructions to get the arithmetic problem. There are two choices of integer and fractional questions. Users can choose their own, when input 1 o'clock will appear 30 integer questions. When input 2 o'clock change input 30 score question.
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace Std;
int main ()
{
int D1, D2, D3, D4, D5, D6, D, I;
int op;
cout << "Please select the type of problem to be done \ n" << Endl;
cout << "Do integer arithmetic input 1 \ n" << "Do score arithmetic input 2\n" << Endl;
Cin >> D;
Srand (Time (NULL));
Switch (D) {
Case 1:
{
for (i = 1; i<; i++)
{
op = rand ()% 4;
Switch (OP)
{
Case 0:
D1 = rand ()% 100;
D2 = rand ()% 100;
cout << d1 << "+" << d2 << "=" << Endl;
Break
Case 1:
D1 = rand ()% 100;
D2 = rand ()% 100;
if (D1 > D2)
cout << d1 << "-" << d2 << "=" << Endl;
Else
cout << D2 << "-" << d1 << "=" << Endl;
Break
Case 2:
D1 = rand ()% 100;
D2 = rand ()% 100;
cout << d1 << "*" << d2 << "=" << Endl;
Break
Case 3:
D1 = rand ()% 100;
D2 = rand ()% 100;
cout << d1 << "/" << d2 << "=" << Endl;
Break
Default:cout << "error\n";
}
}
}
Break
Case 2:
{
for (i = 1; i<30; i++)
{
op = rand ()% 4;
Switch (OP)
{
Case 0:
D1 = rand ()% 100;
D2 = rand ()% 100;
D3 = rand ()% 100;
D4 = rand ()% 100;
cout << "(" << d1 << "/" << D2 << ")" << "+" << "(" << D3 << "/" < ;< d4 << ") =" << Endl;
Break
Case 1:
D1 = rand ()% 100;
D2 = rand ()% 100;
D3 = rand ()% 100;
D4 = rand ()% 100;
if ((D1*D4) > (D2*D3))
cout << "(" << d1 << "/" << D2 << ")" << "-" << "(" << D3 << "/" < ;< d4 << ") =" << Endl;
Else
cout << "(" << d1 << "/" << D4 << ")" << "-" << "(" << D3 << "/" < ;< d2 << ") =" << Endl;
Break
Case 2:
D1 = rand ()% 100;
D2 = rand ()% 100;
D3 = rand ()% 100;
D4 = rand ()% 100;
cout << "(" << d1 << "/" << D2 << ")" << "*" << "(" << D3 << "/" < ;< d4 << ") =" << Endl;
Break
Case 3:
D1 = rand ()% 100;
D2 = rand ()% 100;
D3 = rand ()% 100;
D4 = rand ()% 100;
cout << "(" << d1 << "/" << D2 << ")" << "/" << "(" << D3 << "/" < ;< d4 << ") =" << Endl;
Break
Default:cout << "error\n";
}
}
}
Break
}
System ("pause");
}
The operating interface is as follows
Arithmetic for primary 2 and 2 grade