Soft work second jobs: Familiar tools

GIT address https://github.com/xiaonannanbuchengxian
GIT Username xiaonannanbuchengxian
Student ID after five 61225
blog address https://www.cnblogs.com/xiaonannanbuchengxian/
Job Link https://www.cnblogs.com/harry240/p/11515697.html



Please take a blog record, reflecting the environment configuration process (including what problems encountered, how do you solve)

Environment configuration process did not have much problem, because it is in before are already using VS , so now it seems in retrospect to download a smooth, smooth installation. The beginning do not know how to program in C ++ code, but because the teacher talked about how to use C ++ coding project, you know, so this is very familiar.




Reflect the thinking of the design of your code (Note: please ensure that the code can run through)

First, think about how to design four arithmetic code, and then want to generate random numbers, random operators how to design it, then not so much trouble.
Now, the code below + comment ()

#include <iostream>
#include <time.h>

using namespace std;


int main()
{
    int N,num1, num2, num3, count = 0, result, resultTrue, flag;
    char op1, op2;
    
    cout << "请输入你想生成的题目数目:" << endl;
    cin >> N;//题数
    cout << "这里有" << N << "道题,开始计算吧!";
        
    srand(time(NULL));//生成随机数

    do {
        num1 = rand() % 100 + 1;
        num2 = rand() % 100 + 1;
        num3 = rand() % 100 + 1;

        if (num1 % num2 != 0 || num2 % num3 != 0 || (num1 / num2) % num3 != 0)
        {
            num1 = rand() % 100 + 1;
            num2 = rand() % 100 + 1;
            num3 = rand() % 100 + 1;//保证运算中不会出现小数
        }
        else
    {
            count++;//生成一个算式并计算后count加1
        switch (num1 % 4)//随机生成第一个运算符
        {
        case 0:
            op1 = '+';
            break;
        case 1:
            op1 = '-';
            break;
        case 2:
            op1 = '*';
            break;
        case 3:
            op1 = '/';
            break;
        default:
            break;
        }
        switch (num2 % 4)//同上,随机生成第二个运算符
        {
        case 0:
            op2 = '+';
            flag = 0;
            break;
        case 1:
            op2 = '-';
            flag = 0;
            break;
        case 2:
            op2 = '*';
            if ((op1 == '*') || (op1 == '/')) flag = 0;
            else flag = 1;
            break;
        case 3:
            op2 = '/';
            if ((op1 == '*') || (op1 == '/')) flag = 0;
            else flag = 1;
            break;
        default:
            break;
        }
        cout << num1 << " " << op1 << " " << num2 << " " << op2 << " " << num3 << " " << "=";//生成算术式

        if (flag == 0)//运算先后顺序的确定,flag0为先计算num1,num2,flag1为先计算num2,num3
        {
            resultTrue = 0;
            switch (op1)
            {
            case '+':
                resultTrue = num1 + num2;
                break;
            case '-':
                resultTrue = num1 - num2;
                break;
            case '*':
                resultTrue = num1*num2;
                break;
            case '/':
                resultTrue = num1 / num2;
                break;
            default:
                break;
            }
            switch (op2)
            {
            case '+':
                resultTrue += num3;
                break;
            case '-':
                resultTrue -= num3;
                break;
            case '*':
                resultTrue *= num3;
                break;
            case '/':
                resultTrue /= num3;
                break;
            default:
                break;
            }
        }

        else
        {
            resultTrue = 0;
            switch (op2)
            {
            case '+':
                resultTrue = num2 + num3;
                break;
            case '-':
                resultTrue = num2 - num3;
                break;
            case '*':
                resultTrue = num2*num3;
                break;
            case '/':
                resultTrue = num2 / num3;
                break;
            default:
                break;
            }
            switch (op1)
            {
            case '+':
                resultTrue += num1;
                break;
            case '-':
                resultTrue -= num1;
                break;
            case '*':
                resultTrue *= num1;
                break;
            case '/':
                resultTrue /= num1;
                break;
            default:
                break;
            }
        }

        cin >> result;
        if (result == resultTrue)
            cout << "Right!你真的太棒了!" << endl;
        else
            cout << "faulse!继续加油哦,进行下一题的计算吧!";
    }
    }

    while (count <= N-1);//题数生成终止条件
    return 0;
}

I too hard




Record the entire process you use github clone project and submit the code (including the problems encountered, how you solve)

Cloning project really took me a lot of time, especially in the beginning that what I actually A super warehouse addresses are wrong until later asked the students before they know. That said, after cloning, see the article mentioned - Note that the default branch is cloned java, use git checkout cplusplus command to switch to C ++ project, I spent a lot of time here, have been thinking, the online search to find out how no conversion to know other ways also, hey, I'm too hard - after conversion, the result ask the students

to Cherish's a super four arithmetic generator cloned into their warehouse.

The A super four arithmetic generator project cloned into a local file.

Git commit -m command to commit the snapshot file project. git status to see whether the current file complete snapshot to the project.

git push to speak directly to the Github project pushed the original project.

Here you can see online warehouse has been uploaded files.
Note: The landing operation ...... forget the screenshot uncomfortable.




Recording your unit tests and regression testing of the project (including your problem, what solution is)

Unit testing is actually testing out. Front steps seem relatively smoothly, but the introduction of interface definition header file Calculator project , it will not do ...... (to be continued ... see below)



it was here that should have introduced Calculator works interface definition header file screenshot, but I feel like I skipped, but the test results came out, it seems right.

Thoughts:, I ... I'm too hard, difficult for me, difficult for me ah! This makes the job really learn a lot, do not know to ask , to use Git and Github to learn more about the familiar, there is also a unit and regression testing, and more understanding, I would say, self stuff there many, they are waiting for me to learn, it is worth me to learn, and I have to spend more time to learn.

Guess you like

Origin www.cnblogs.com/xiaonannanbuchengxian/p/11564390.html