ソフトセカンド使い慣れたツールの作業

ソフト仕事副業

使い慣れたツール

GITアドレス https://github.com/Corvvus
GITユーザー名 Corvvus
5後の学生のID 61426
ブログのアドレス https://www.cnblogs.com/zhangzhuoxin/
ジョブリンク https://www.cnblogs.com/harry240/p/11515697.html

コンフィギュレーション・プロセス

1.ダウンロードvs2017

nz8i8O.png

C ++の設定環境をダウンロード
2.ダウンロードgitの
nz8mVI.png

3.スーパーは、あなたのライブラリにライブラリを保存します

ファイルディレクトリのgitブッシュ4.、お近くにライブラリファイルを保存します

nz8rM4.png

5.元のJavaは、cppのファイルにファイル

nz8fJK.png
6対にソースコードとヘッダファイルをコピーします

nzGCes.png

コード

ヘッダ

#pragma once
#include "stdlib.h"
#include <stack>
#include <vector>
#include <iostream>
#include "stdlib.h"
#include <ctime>
#include <string>  
#include "../Calculator/calculator.h"
using namespace std;

class Calculator {
private:
    string op[4] = { "+", "-", "*", "/" };
public:
    Calculator();
    string MakeFormula();
    string Solve(string formula);
};

ソース

// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include "pch.h"
#include <iostream>

#include <stdlib.h>
#include <stack>
#include <vector>
#include <iostream>
#include "stdlib.h"
#include <ctime>
#include <string>
#include "Calculator.h"

#define random(a,b) (rand()%(b-a+1)+a)

using namespace std;

Calculator::Calculator() {}

string Calculator::MakeFormula() {
    string formula = "";
    //srand((unsigned int)time(NULL));
    int count = random(1, 3);
    int start = 0;
    int number1 = random(1, 100);
    formula += to_string(number1);
    while (start <= count) {
        int operation = random(0, 3);
        int number2 = random(1, 100);
        formula += op[operation] + to_string(number2);
        start++;
    }
    return formula;
};

string Calculator::Solve(string formula) {
    vector<string>* tempStack = new vector<string>();
    stack<char>* operatorStack = new stack<char>();
    int len = formula.length();
    int k = 0;
    for (int j = -1; j < len - 1; j++) {
        char formulaChar = formula[j + 1];
        if (j == len - 2 || formulaChar == '+' || formulaChar == '-' ||
            formulaChar == '*' || formulaChar == '/') {
            if (j == len - 2) {
                tempStack->push_back(formula.substr(k));
            }
            else {
                if (k < j) {
                    tempStack->push_back(formula.substr(k, j + 1));
                }
                if (operatorStack->empty()) {
                    operatorStack->push(formulaChar);
                }
                else {
                    char stackChar = operatorStack->top();
                    if ((stackChar == '+' || stackChar == '-')
                        && (formulaChar == '*' || formulaChar == '/')) {
                        operatorStack->push(formulaChar);
                    }
                    else {
                        tempStack->push_back(to_string(operatorStack->top()));
                        operatorStack->pop();
                        operatorStack->push(formulaChar);
                    }
                }
            }
            k = j + 2;
        }
    }
    while (!operatorStack->empty()) {
        tempStack->push_back(string(1, operatorStack->top()));
        operatorStack->pop();
    }
    stack<string>* calcStack = new stack<string>();
    for (int i = 0; i < tempStack->size(); i++) {
        string peekChar = tempStack->at(i);
        if (peekChar != "+" && peekChar != "-"
            && peekChar != "/" && peekChar != "*") {
            calcStack->push(peekChar);
        }
        else {
            int a1 = 0;
            int b1 = 0;
            if (!calcStack->empty()) {
                b1 = stoi(calcStack->top());
                calcStack->pop();
            }
            if (!calcStack->empty()) {
                a1 = stoi(calcStack->top());
                calcStack->pop();
            }
            if (peekChar == "+") {
                calcStack->push(to_string(a1 + b1));
            }
            else if (peekChar == "-") {
                calcStack->push(to_string(a1 - b1));
            }
            else if (peekChar == "*") {
                calcStack->push(to_string(a1 * b1));
            }
            else if (peekChar == "/") {
                calcStack->push(to_string(a1 / b1));
            }
        }
    }
    return formula + "=" + calcStack->top();
}

int main()
{
    srand((unsigned int)time(NULL));
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        Calculator* calc = new Calculator();
        string question = calc->MakeFormula();
        cout << question <<" = "<< endl;
        //string ret = calc->Solve(question);
        //cout << ret << endl;
    }
    getchar();
}



// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门提示: 
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件

ランニング後のスクリーンショット
nzJY40.png

呼び出されたときには、繰り返し同じ式に表示されないよう文書では、私はMakeFormula文字列電卓を発行します::ランダム()関数は、メイン機能で生成されます

githubのクローンのプロジェクトを使用してコードを提出する
オープンgitのを、ローカルでのGitのプッシュ入力ファイル
nzJdvF.png

2.アップロード完全な
nzJDb9.png

感情と共有

私たちはgitのとvs2017、今回の仕事の経験、ファイルをダウンロードし、上記のファイルをアップロードする方法を知って、一定の理解をgitのためのに慣れていないので、ブログのヘッドは、本当に素晴らしいですが、私は将来的に働きたいですまた、新しいツールを習得するための独自のを必要とするので、あなたがこれまでに成長しており、学習に知識を習得する必要があります、それは時代によって排除されることはありません。

おすすめ

転載: www.cnblogs.com/zhangzhuoxin/p/11564262.html
おすすめ