diff --git a/Cuogeihong/Calculator/.vs/Calculator/v15/.suo b/Cuogeihong/Calculator/.vs/Calculator/v15/.suo new file mode 100644 index 00000000..afcde649 Binary files /dev/null and b/Cuogeihong/Calculator/.vs/Calculator/v15/.suo differ diff --git a/Cuogeihong/Calculator/.vs/Calculator/v15/Browse.VC.db b/Cuogeihong/Calculator/.vs/Calculator/v15/Browse.VC.db new file mode 100644 index 00000000..dc4f351d Binary files /dev/null and b/Cuogeihong/Calculator/.vs/Calculator/v15/Browse.VC.db differ diff --git a/Cuogeihong/Calculator/.vs/Calculator/v15/Solution.VC.db b/Cuogeihong/Calculator/.vs/Calculator/v15/Solution.VC.db new file mode 100644 index 00000000..eb3a1578 Binary files /dev/null and b/Cuogeihong/Calculator/.vs/Calculator/v15/Solution.VC.db differ diff --git a/Cuogeihong/Calculator/.vs/Calculator/v15/ipch/6777aa84edefd93e.ipch b/Cuogeihong/Calculator/.vs/Calculator/v15/ipch/6777aa84edefd93e.ipch new file mode 100644 index 00000000..12a96ad2 Binary files /dev/null and b/Cuogeihong/Calculator/.vs/Calculator/v15/ipch/6777aa84edefd93e.ipch differ diff --git a/Cuogeihong/Calculator/.vs/Calculator/v15/ipch/ecb8fd3bb6e2dc69.ipch b/Cuogeihong/Calculator/.vs/Calculator/v15/ipch/ecb8fd3bb6e2dc69.ipch new file mode 100644 index 00000000..984c1a2d Binary files /dev/null and b/Cuogeihong/Calculator/.vs/Calculator/v15/ipch/ecb8fd3bb6e2dc69.ipch differ diff --git a/Cuogeihong/Calculator/.vs/Calculator/v15/ipch/f331e8d499b20f66.ipch b/Cuogeihong/Calculator/.vs/Calculator/v15/ipch/f331e8d499b20f66.ipch new file mode 100644 index 00000000..f8ddb0aa Binary files /dev/null and b/Cuogeihong/Calculator/.vs/Calculator/v15/ipch/f331e8d499b20f66.ipch differ diff --git a/Cuogeihong/Calculator/Calculator.sln b/Cuogeihong/Calculator/Calculator.sln new file mode 100644 index 00000000..a5d7c0b8 --- /dev/null +++ b/Cuogeihong/Calculator/Calculator.sln @@ -0,0 +1,41 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.421 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Calculator", "Calculator\Calculator.vcxproj", "{FEF1EAB2-AA5E-4060-82D6-067820651E2D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalculatorUnitTest", "CalculatorUnitTest\CalculatorUnitTest.vcxproj", "{A5F81C3A-5DFB-463E-8C29-9F62507C1ADE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FEF1EAB2-AA5E-4060-82D6-067820651E2D}.Debug|x64.ActiveCfg = Debug|x64 + {FEF1EAB2-AA5E-4060-82D6-067820651E2D}.Debug|x64.Build.0 = Debug|x64 + {FEF1EAB2-AA5E-4060-82D6-067820651E2D}.Debug|x86.ActiveCfg = Debug|Win32 + {FEF1EAB2-AA5E-4060-82D6-067820651E2D}.Debug|x86.Build.0 = Debug|Win32 + {FEF1EAB2-AA5E-4060-82D6-067820651E2D}.Release|x64.ActiveCfg = Release|x64 + {FEF1EAB2-AA5E-4060-82D6-067820651E2D}.Release|x64.Build.0 = Release|x64 + {FEF1EAB2-AA5E-4060-82D6-067820651E2D}.Release|x86.ActiveCfg = Release|Win32 + {FEF1EAB2-AA5E-4060-82D6-067820651E2D}.Release|x86.Build.0 = Release|Win32 + {A5F81C3A-5DFB-463E-8C29-9F62507C1ADE}.Debug|x64.ActiveCfg = Debug|x64 + {A5F81C3A-5DFB-463E-8C29-9F62507C1ADE}.Debug|x64.Build.0 = Debug|x64 + {A5F81C3A-5DFB-463E-8C29-9F62507C1ADE}.Debug|x86.ActiveCfg = Debug|Win32 + {A5F81C3A-5DFB-463E-8C29-9F62507C1ADE}.Debug|x86.Build.0 = Debug|Win32 + {A5F81C3A-5DFB-463E-8C29-9F62507C1ADE}.Release|x64.ActiveCfg = Release|x64 + {A5F81C3A-5DFB-463E-8C29-9F62507C1ADE}.Release|x64.Build.0 = Release|x64 + {A5F81C3A-5DFB-463E-8C29-9F62507C1ADE}.Release|x86.ActiveCfg = Release|Win32 + {A5F81C3A-5DFB-463E-8C29-9F62507C1ADE}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EBAEF9CF-A961-4E51-BE7C-5E103AC34F9C} + EndGlobalSection +EndGlobal diff --git a/Cuogeihong/Calculator/Calculator.sln.DotSettings.user b/Cuogeihong/Calculator/Calculator.sln.DotSettings.user new file mode 100644 index 00000000..99e3685b --- /dev/null +++ b/Cuogeihong/Calculator/Calculator.sln.DotSettings.user @@ -0,0 +1,3 @@ + + True + True \ No newline at end of file diff --git a/Cuogeihong/Calculator/Calculator/Calculator.cpp b/Cuogeihong/Calculator/Calculator/Calculator.cpp new file mode 100644 index 00000000..86f02b50 --- /dev/null +++ b/Cuogeihong/Calculator/Calculator/Calculator.cpp @@ -0,0 +1,199 @@ + + +#include "pch.h" +#include +#include +#include +#include "stdlib.h" +#include +#include +#include "Calculator.h" + +#define random(a,b) (rand()%(b-a+1)+a) + +using namespace std; + +Calculator::Calculator() {} + +string Calculator::MakeFormula() { + srand((unsigned int)time(NULL)); + while (true) { + string formula = ""; + int count = random(1, 2); + int start = 0; + int number1 = random(0, 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++; + } + if (Adjust(formula)) { + return formula; //采用暴力方法判断整除,存在很大问题,效率不好且答案很可能没有除法 + } + } +}; + +bool Calculator::Adjust(string formula) { + vector* tempStack = new vector(); + stack* operatorStack = new stack(); + 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 - k + 1)); + } + if (operatorStack->empty()) { + operatorStack->push(formulaChar); + } + else { + char stackChar = operatorStack->top(); + if ((stackChar == '+' || stackChar == '-') + && (formulaChar == '*' || formulaChar == '/')) { + operatorStack->push(formulaChar); + } + else { + tempStack->push_back(string(1, operatorStack->top())); + operatorStack->pop(); + operatorStack->push(formulaChar); + } + } + } + k = j + 2; + } + } + while (!operatorStack->empty()) { + tempStack->push_back(string(1, operatorStack->top())); + operatorStack->pop(); + } + stack* calcStack = new stack(); + 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)); + if (a1 % b1 != 0) { + return false; + } + } + } + } + return true; +} + +string Calculator::Solve(string formula) { + vector* tempStack = new vector(); + stack* operatorStack = new stack(); + 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 - k + 1)); + } + if (operatorStack->empty()) { + operatorStack->push(formulaChar); + } + else { + char stackChar = operatorStack->top(); + if ((stackChar == '+' || stackChar == '-') + && (formulaChar == '*' || formulaChar == '/')) { + operatorStack->push(formulaChar); + } + else { + tempStack->push_back(string(1, operatorStack->top())); + operatorStack->pop(); + operatorStack->push(formulaChar); + } + } + } + k = j + 2; + } + } + while (!operatorStack->empty()) { + tempStack->push_back(string(1, operatorStack->top())); + operatorStack->pop(); + } + stack* calcStack = new stack(); + 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() +{ + Calculator* calc = new Calculator(); + string question = calc->MakeFormula(); + cout << question << endl; + string ret = calc->Solve("11+22"); + cout << ret << endl; + getchar(); +} + + diff --git a/Cuogeihong/Calculator/Calculator/Calculator.h b/Cuogeihong/Calculator/Calculator/Calculator.h new file mode 100644 index 00000000..f6f8642b --- /dev/null +++ b/Cuogeihong/Calculator/Calculator/Calculator.h @@ -0,0 +1,19 @@ +#pragma once +#include "pch.h" +#include +#include +#include +#include "stdlib.h" +#include +#include +using namespace std; + +class Calculator { +private: + string op[4] = { "+", "-", "*", "/" }; +public: + Calculator(); + string MakeFormula(); + string Solve(string formula); + bool Adjust(string formula); +}; diff --git a/Cuogeihong/Calculator/Calculator/Calculator.vcxproj b/Cuogeihong/Calculator/Calculator/Calculator.vcxproj new file mode 100644 index 00000000..ce6befec --- /dev/null +++ b/Cuogeihong/Calculator/Calculator/Calculator.vcxproj @@ -0,0 +1,170 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {FEF1EAB2-AA5E-4060-82D6-067820651E2D} + Win32Proj + Calculator + 10.0.17763.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib + + + + + Use + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/Cuogeihong/Calculator/Calculator/Calculator.vcxproj.filters b/Cuogeihong/Calculator/Calculator/Calculator.vcxproj.filters new file mode 100644 index 00000000..51584858 --- /dev/null +++ b/Cuogeihong/Calculator/Calculator/Calculator.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/Cuogeihong/Calculator/Calculator/Calculator.vcxproj.user b/Cuogeihong/Calculator/Calculator/Calculator.vcxproj.user new file mode 100644 index 00000000..be250787 --- /dev/null +++ b/Cuogeihong/Calculator/Calculator/Calculator.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Cuogeihong/Calculator/Calculator/Debug/Calculator.log b/Cuogeihong/Calculator/Calculator/Debug/Calculator.log new file mode 100644 index 00000000..c37ab5b4 --- /dev/null +++ b/Cuogeihong/Calculator/Calculator/Debug/Calculator.log @@ -0,0 +1,4 @@ + Calculator.cpp +e:\jobs\se\calculator\cuogeihong\calculator\calculator\calculator.cpp(78): warning C4018: “<”: 有符号/无符号不匹配 +e:\jobs\se\calculator\cuogeihong\calculator\calculator\calculator.cpp(155): warning C4018: “<”: 有符号/无符号不匹配 + Calculator.vcxproj -> E:\jobs\SE\Calculator\Cuogeihong\Calculator\Debug\Calculator.exe diff --git a/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/CL.command.1.tlog b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/CL.command.1.tlog new file mode 100644 index 00000000..4f2b711a Binary files /dev/null and b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/CL.command.1.tlog differ diff --git a/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/CL.read.1.tlog b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/CL.read.1.tlog new file mode 100644 index 00000000..c0816a5c Binary files /dev/null and b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/CL.read.1.tlog differ diff --git a/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/CL.write.1.tlog b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/CL.write.1.tlog new file mode 100644 index 00000000..83d2577c Binary files /dev/null and b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/CL.write.1.tlog differ diff --git a/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/Calculator.lastbuildstate b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/Calculator.lastbuildstate new file mode 100644 index 00000000..b530a0b6 --- /dev/null +++ b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/Calculator.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 +Debug|Win32|E:\jobs\SE\Calculator\Cuogeihong\Calculator\| diff --git a/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/link.command.1.tlog b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/link.command.1.tlog new file mode 100644 index 00000000..bdfa2f8d Binary files /dev/null and b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/link.command.1.tlog differ diff --git a/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/link.read.1.tlog b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/link.read.1.tlog new file mode 100644 index 00000000..0e1a3177 Binary files /dev/null and b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/link.read.1.tlog differ diff --git a/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/link.write.1.tlog b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/link.write.1.tlog new file mode 100644 index 00000000..6e2338ec Binary files /dev/null and b/Cuogeihong/Calculator/Calculator/Debug/Calculator.tlog/link.write.1.tlog differ diff --git a/Cuogeihong/Calculator/Calculator/Debug/vc141.idb b/Cuogeihong/Calculator/Calculator/Debug/vc141.idb new file mode 100644 index 00000000..226558ec Binary files /dev/null and b/Cuogeihong/Calculator/Calculator/Debug/vc141.idb differ diff --git a/Cuogeihong/Calculator/Calculator/Debug/vc141.pdb b/Cuogeihong/Calculator/Calculator/Debug/vc141.pdb new file mode 100644 index 00000000..5f924b84 Binary files /dev/null and b/Cuogeihong/Calculator/Calculator/Debug/vc141.pdb differ diff --git a/Cuogeihong/Calculator/Calculator/pch.cpp b/Cuogeihong/Calculator/Calculator/pch.cpp new file mode 100644 index 00000000..8eb50d04 --- /dev/null +++ b/Cuogeihong/Calculator/Calculator/pch.cpp @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件;编译成功所必需的 + +#include "pch.h" + +// 一般情况下,忽略此文件,但如果你使用的是预编译标头,请保留它。 diff --git a/Cuogeihong/Calculator/Calculator/pch.h b/Cuogeihong/Calculator/Calculator/pch.h new file mode 100644 index 00000000..69bf59d2 --- /dev/null +++ b/Cuogeihong/Calculator/Calculator/pch.h @@ -0,0 +1,14 @@ +// 入门提示: +// 1. 使用解决方案资源管理器窗口添加/管理文件 +// 2. 使用团队资源管理器窗口连接到源代码管理 +// 3. 使用输出窗口查看生成输出和其他消息 +// 4. 使用错误列表窗口查看错误 +// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目 +// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件 + +#ifndef PCH_H +#define PCH_H + +// TODO: 添加要在此处预编译的标头 + +#endif //PCH_H diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/CalculatorUnitTest.vcxproj b/Cuogeihong/Calculator/CalculatorUnitTest/CalculatorUnitTest.vcxproj new file mode 100644 index 00000000..2df5b900 --- /dev/null +++ b/Cuogeihong/Calculator/CalculatorUnitTest/CalculatorUnitTest.vcxproj @@ -0,0 +1,176 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {A5F81C3A-5DFB-463E-8C29-9F62507C1ADE} + Win32Proj + CalculatorUnitTest + 10.0.17763.0 + NativeUnitTestProject + + + + DynamicLibrary + true + v141 + Unicode + false + + + DynamicLibrary + false + v141 + true + Unicode + false + + + DynamicLibrary + true + v141 + Unicode + false + + + DynamicLibrary + false + v141 + true + Unicode + false + + + + + + + + + + + + + + + + + + + + + true + + + true + + + true + + + true + + + + Use + Level3 + Disabled + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;%(PreprocessorDefinitions) + true + + + Windows + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + ..\Calculator\Debug\Calculator.obj;..\Calculator\Debug\pch.obj + + + + + Use + Level3 + Disabled + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + _DEBUG;%(PreprocessorDefinitions) + true + + + Windows + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + + + + + Create + Create + Create + Create + + + + + + {fef1eab2-aa5e-4060-82d6-067820651e2d} + + + + + + \ No newline at end of file diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/CalculatorUnitTest.vcxproj.filters b/Cuogeihong/Calculator/CalculatorUnitTest/CalculatorUnitTest.vcxproj.filters new file mode 100644 index 00000000..a3bc7845 --- /dev/null +++ b/Cuogeihong/Calculator/CalculatorUnitTest/CalculatorUnitTest.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/CalculatorUnitTest.vcxproj.user b/Cuogeihong/Calculator/CalculatorUnitTest/CalculatorUnitTest.vcxproj.user new file mode 100644 index 00000000..be250787 --- /dev/null +++ b/Cuogeihong/Calculator/CalculatorUnitTest/CalculatorUnitTest.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CL.command.1.tlog b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CL.command.1.tlog new file mode 100644 index 00000000..7a4b096b Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CL.command.1.tlog differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CL.read.1.tlog b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CL.read.1.tlog new file mode 100644 index 00000000..97c84bad Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CL.read.1.tlog differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CL.write.1.tlog b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CL.write.1.tlog new file mode 100644 index 00000000..cc910573 Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CL.write.1.tlog differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CalculatorUnitTest.lastbuildstate b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CalculatorUnitTest.lastbuildstate new file mode 100644 index 00000000..b530a0b6 --- /dev/null +++ b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CalculatorUnitTest.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 +Debug|Win32|E:\jobs\SE\Calculator\Cuogeihong\Calculator\| diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CalculatorUnitTest.write.1u.tlog b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CalculatorUnitTest.write.1u.tlog new file mode 100644 index 00000000..08c13885 Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/CalculatorUnitTest.write.1u.tlog differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.11736.delete.1.tlog b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.11736.delete.1.tlog new file mode 100644 index 00000000..81725b7c Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.11736.delete.1.tlog differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.13832.delete.1.tlog b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.13832.delete.1.tlog new file mode 100644 index 00000000..e7f45ff7 Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.13832.delete.1.tlog differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.20524.delete.1.tlog b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.20524.delete.1.tlog new file mode 100644 index 00000000..9ebe8030 Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.20524.delete.1.tlog differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.21200.delete.1.tlog b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.21200.delete.1.tlog new file mode 100644 index 00000000..3cabb3fb Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.21200.delete.1.tlog differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.command.1.tlog b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.command.1.tlog new file mode 100644 index 00000000..777fad6b Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.command.1.tlog differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.read.1.tlog b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.read.1.tlog new file mode 100644 index 00000000..a9eb4657 Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.read.1.tlog differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.write.1.tlog b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.write.1.tlog new file mode 100644 index 00000000..b0c99cd3 Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/Calculat.A5F81C3A.tlog/link.write.1.tlog differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/CalculatorUnitTest.log b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/CalculatorUnitTest.log new file mode 100644 index 00000000..933cdbe1 --- /dev/null +++ b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/CalculatorUnitTest.log @@ -0,0 +1,3 @@ + unittest1.cpp + 正在创建库 E:\jobs\SE\Calculator\Cuogeihong\Calculator\Debug\CalculatorUnitTest.lib 和对象 E:\jobs\SE\Calculator\Cuogeihong\Calculator\Debug\CalculatorUnitTest.exp + CalculatorUnitTest.vcxproj -> E:\jobs\SE\Calculator\Cuogeihong\Calculator\Debug\CalculatorUnitTest.dll diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/vc141.idb b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/vc141.idb new file mode 100644 index 00000000..09356996 Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/vc141.idb differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/Debug/vc141.pdb b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/vc141.pdb new file mode 100644 index 00000000..30884419 Binary files /dev/null and b/Cuogeihong/Calculator/CalculatorUnitTest/Debug/vc141.pdb differ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/stdafx.cpp b/Cuogeihong/Calculator/CalculatorUnitTest/stdafx.cpp new file mode 100644 index 00000000..a0031370 --- /dev/null +++ b/Cuogeihong/Calculator/CalculatorUnitTest/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// CalculatorUnitTest.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H κĸͷļ +//ڴļ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/stdafx.h b/Cuogeihong/Calculator/CalculatorUnitTest/stdafx.h new file mode 100644 index 00000000..3a1e49d2 --- /dev/null +++ b/Cuogeihong/Calculator/CalculatorUnitTest/stdafx.h @@ -0,0 +1,13 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +// CppUnitTest ͷļ +#include "CppUnitTest.h" + +// TODO: ڴ˴óҪͷļ diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/targetver.h b/Cuogeihong/Calculator/CalculatorUnitTest/targetver.h new file mode 100644 index 00000000..416cebf8 --- /dev/null +++ b/Cuogeihong/Calculator/CalculatorUnitTest/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h õ߰汾 Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// _WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/Cuogeihong/Calculator/CalculatorUnitTest/unittest1.cpp b/Cuogeihong/Calculator/CalculatorUnitTest/unittest1.cpp new file mode 100644 index 00000000..61f278b9 --- /dev/null +++ b/Cuogeihong/Calculator/CalculatorUnitTest/unittest1.cpp @@ -0,0 +1,77 @@ +#include "stdafx.h" +#include "CppUnitTest.h" +#include "../Calculator/Calculator.h" + +using namespace Microsoft::VisualStudio::CppUnitTestFramework; + +namespace CalculatorUnitTest +{ + TEST_CLASS(UnitTest1) + { + public: + + TEST_METHOD(TestMethod1) + { + // TODO: ڴԴ + Calculator* calc = new Calculator(); + string ret = calc->Solve("11+22"); + Assert::AreEqual(ret, (string)"11+22=33"); + } + TEST_METHOD(TestMethod2) + { + // TODO: ڴԴ + Calculator* calc = new Calculator(); + string ret = calc->Solve("11+34"); + Assert::AreEqual(ret, (string)"11+34=45"); + } + TEST_METHOD(TestMethod3) + { + // TODO: ڴԴ + Calculator* calc = new Calculator(); + string ret = calc->Solve("13+17-1"); + Assert::AreEqual(ret, (string)"13+17-1=29"); + } + TEST_METHOD(TestMethod4) + { + // TODO: ڴԴ + Calculator* calc = new Calculator(); + string ret = calc->Solve("11*15-5"); + Assert::AreEqual(ret, (string)"11*15-5=160"); + } + TEST_METHOD(TestMethod5) + { + // TODO: ڴԴ + Calculator* calc = new Calculator(); + string ret = calc->Solve("3+10+4-16"); + Assert::AreEqual(ret, (string)"3+10+4-16=1"); + } + TEST_METHOD(TestMethod6) + { + // TODO: ڴԴ + Calculator* calc = new Calculator(); + string ret = calc->Solve("15/5+3-2"); + Assert::AreEqual(ret, (string)"15/5+3-2=4"); + } + TEST_METHOD(TestMethod7) + { + // TODO: ڴԴ + Calculator* calc = new Calculator(); + string ret = calc->Solve("24/4/6"); + Assert::AreEqual(ret, (string)"24/4/6=1"); + } + TEST_METHOD(TestMethod8) + { + // TODO: ڴԴ + Calculator* calc = new Calculator(); + string ret = calc->Solve("24+12/6"); + Assert::AreEqual(ret, (string)"24+12/6=26"); + } + TEST_METHOD(TestMethod9) + { + // TODO: ڴԴ + Calculator* calc = new Calculator(); + string ret = calc->Solve("24+12/6-1"); + Assert::AreEqual(ret, (string)"24+12/6-1=25"); + } + }; +} \ No newline at end of file diff --git a/Cuogeihong/Calculator/Debug/Calculator.ilk b/Cuogeihong/Calculator/Debug/Calculator.ilk new file mode 100644 index 00000000..0ea379cc Binary files /dev/null and b/Cuogeihong/Calculator/Debug/Calculator.ilk differ diff --git a/Cuogeihong/Calculator/Debug/Calculator.pdb b/Cuogeihong/Calculator/Debug/Calculator.pdb new file mode 100644 index 00000000..65279a4e Binary files /dev/null and b/Cuogeihong/Calculator/Debug/Calculator.pdb differ diff --git a/Cuogeihong/Calculator/Debug/CalculatorUnitTest.exp b/Cuogeihong/Calculator/Debug/CalculatorUnitTest.exp new file mode 100644 index 00000000..5a81e0af Binary files /dev/null and b/Cuogeihong/Calculator/Debug/CalculatorUnitTest.exp differ diff --git a/Cuogeihong/Calculator/Debug/CalculatorUnitTest.ilk b/Cuogeihong/Calculator/Debug/CalculatorUnitTest.ilk new file mode 100644 index 00000000..b20acb78 Binary files /dev/null and b/Cuogeihong/Calculator/Debug/CalculatorUnitTest.ilk differ diff --git a/Cuogeihong/Calculator/Debug/CalculatorUnitTest.pdb b/Cuogeihong/Calculator/Debug/CalculatorUnitTest.pdb new file mode 100644 index 00000000..82186006 Binary files /dev/null and b/Cuogeihong/Calculator/Debug/CalculatorUnitTest.pdb differ diff --git "a/Cuogeihong/Calculator/\346\212\245\345\221\21220200303-1522.vspx" "b/Cuogeihong/Calculator/\346\212\245\345\221\21220200303-1522.vspx" new file mode 100644 index 00000000..6865c260 Binary files /dev/null and "b/Cuogeihong/Calculator/\346\212\245\345\221\21220200303-1522.vspx" differ