Arithmetic for primary 2 and 2 grade

Source: Internet
Author: User

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 << "/" &lt ;< 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 << "/" &lt ;< d4 << ") =" << Endl;
Else
cout << "(" << d1 << "/" << D4 << ")" << "-" << "(" << D3 << "/" &lt ;< d2 << ") =" << Endl;
Break
Case 2:
D1 = rand ()% 100;
D2 = rand ()% 100;
D3 = rand ()% 100;
D4 = rand ()% 100;
cout << "(" << d1 << "/" << D2 << ")" << "*" << "(" << D3 << "/" &lt ;< d4 << ") =" << Endl;
Break
Case 3:
D1 = rand ()% 100;
D2 = rand ()% 100;
D3 = rand ()% 100;
D4 = rand ()% 100;
cout << "(" << d1 << "/" << D2 << ")" << "/" << "(" << D3 << "/" &lt ;< d4 << ") =" << Endl;
Break
Default:cout << "error\n";
}
}
}
Break
}
System ("pause");
}

The operating interface is as follows

Arithmetic for primary 2 and 2 grade

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.