Software Second job: Familiar tools

Git address https://github.com/doraemon-n/dora
Git user name doraemon-n
Student ID after five 61205
blog address https://www.cnblogs.com/summer-00/
Job Link https://www.cnblogs.com/ChildishChange/p/10398212.htm

VS install Git and learning

Vs installation package to find on the Internet and check the corresponding things I needed to start the download (since it already has before vs, so there is no screenshot), look https://www.cnblogs.com/math/p /git.html understand the fundamental role of Git, how to use.
Problems encountered is probably very slow to download, Git is in English, not familiar with the new environment
***

Create a project

Open vs, point to New -> Project -> c ++ to create a project to start writing my code


Code ideas

Background
A super children at home on the first grade , and this summer the teachers to the parents arranged a job: parents give children every day some reasonable, but some difficulty four arithmetic topics , and parents to the child's job scoring record . Exercises in the course of operation must not appear non-integer .
Design
(1) four operators: the topic of four operators should be random, it is possible to think of using a random function srand (), only four operators (+, -, *, /), it is mentioned manner array out (or use enum).

char operate()//获取随机运算符
{
    int seed;//随机数种子
    cout << "请输入随机数种子以产生运算符"<<endl;
    cin >> seed;
    char ope[4] = { '+','-','*','/' };
    srand(seed); 
    return ope[rand() % 4];
}

(2) Number of four arithmetic operations: calculating a number between 0 and 100, so there are 1 + rand ()% 100, since the first grade, the calculation result is not score calculation process data points can not occur.

int num()//获取随机数
{
    int seed;
    cout << "请输入随机数种子以产生0~100的数字" << endl;
    cin >> seed;
    srand(seed);
    return 1 + rand() % 100;
}

(3) complete code, limited capacity, and not a file, run the interface is not the same.

#include "pch.h"
#include <iostream>
#include<cstdlib>
#include<fstream>
using namespace std;


char operate()//获取随机运算符
{
    int seed;
    cout << "请输入随机数种子以产生运算符"<<endl;
    cin >> seed;
    char ope[4] = { '+','-','*','/' };
    srand(seed); 
    return ope[rand() % 4];
}
int num()//获取随机数
{
    int seed;
    cout << "请输入随机数种子以产生0~100的数字" << endl;
    cin >> seed;
    srand(seed);
    return 1 + rand() % 100;
}

int main()
{
    int n;
    char char_1,char_2;
    int num1, num2, num3, operate_num;

    cout << "请输入你想要的题目总数" << endl;
    cin >> n;

    while (n)//while循环,以产生对应数目的题
    {
        cout << "请输入操作符数目(2或3)来确定运算数的数目" << endl;
        cin >> operate_num;
        if (operate_num == 2)//有三个运算数,两个运算符
        {
            num1 = num();
            num2 = num();
            num3 = num();
            cout << "三个随机运算数为" << num1 << ";" << num2 << ";" << num3 << endl;
            char_1 = operate();
            char_2 = operate();
            cout << "两个随机运算符为" << char_1 << ";" << char_2 << endl;
            cout << num1 << char_1 << num2 << char_2 << num3 << "= " << endl;
        }

        else if (operate_num == 3)//有四个运算数,三个运算符
        {
            int num4;
            char char_3;
            num1 = num();
            num2 = num();
            num3 = num();
            num4 = num();
            cout << "四个随机运算数为" << num1 << ";" << num2 << ";" << num3 << ";" << num4 << endl;
            char_1 = operate();
            char_2 = operate();
            char_3 = operate();
            cout << "三个随机运算符为" << char_1 << ";" << char_2 << ";" << char_3 << endl;
            cout << num1 << char_1 << num2 << char_2 << num3 << char_3 << num4 << "= " << endl;
        }
        n--;
    }
    return 0;
}

result

请输入你想要的题目总数
2
49*52-55=
52/55*59+62=

GitHub clone

Test problem

The code at run time seem complicated, the results can not guarantee non-integer not appear.

Impressions

Learning to use a new tool or a little troublesome, especially the interface is in English, but after constant trial and error will slowly accustomed to understand. In the process of writing code, most do not know how to start randomly generate different operators, by constantly thinking about selecting an array, in the process of writing your own code, in fact, there are a lot of unnecessary, but limited ability to I feel that they should practice a variety of different kinds of questions. Then that they really do not know necessarily going to ask someone else to figure it out or Baidu. Assistant to the operation has been very clear, but they still can not understand some places, because some steps out of the results of operations, said the link is not the same, wondering what step does not own.

Guess you like

Origin www.cnblogs.com/summer-00/p/11563958.html