Skip to content
Open

test #117

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added mjjm3/Cal/.vs/Cal/v16/.suo
Binary file not shown.
Binary file added mjjm3/Cal/.vs/Cal/v16/Browse.VC.db
Binary file not shown.
Binary file added mjjm3/Cal/.vs/Cal/v16/Solution.VC.db
Binary file not shown.
Binary file not shown.
Binary file added mjjm3/Cal/.vs/Cal/v16/TestStore/0/testlog.manifest
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added mjjm3/Cal/.vs/Cal/v16/ipch/fcc087e713233fe8.ipch
Binary file not shown.
41 changes: 41 additions & 0 deletions mjjm3/Cal/Cal.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29230.47
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cal", "Cal\Cal.vcxproj", "{F46B48A6-B8B7-4E00-87D9-252FB365A170}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalUnitTest", "CalUnitTest\CalUnitTest.vcxproj", "{A0DAFF64-97E0-49BF-94C7-110551C1B1B3}"
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
{F46B48A6-B8B7-4E00-87D9-252FB365A170}.Debug|x64.ActiveCfg = Debug|x64
{F46B48A6-B8B7-4E00-87D9-252FB365A170}.Debug|x64.Build.0 = Debug|x64
{F46B48A6-B8B7-4E00-87D9-252FB365A170}.Debug|x86.ActiveCfg = Debug|Win32
{F46B48A6-B8B7-4E00-87D9-252FB365A170}.Debug|x86.Build.0 = Debug|Win32
{F46B48A6-B8B7-4E00-87D9-252FB365A170}.Release|x64.ActiveCfg = Release|x64
{F46B48A6-B8B7-4E00-87D9-252FB365A170}.Release|x64.Build.0 = Release|x64
{F46B48A6-B8B7-4E00-87D9-252FB365A170}.Release|x86.ActiveCfg = Release|Win32
{F46B48A6-B8B7-4E00-87D9-252FB365A170}.Release|x86.Build.0 = Release|Win32
{A0DAFF64-97E0-49BF-94C7-110551C1B1B3}.Debug|x64.ActiveCfg = Debug|x64
{A0DAFF64-97E0-49BF-94C7-110551C1B1B3}.Debug|x64.Build.0 = Debug|x64
{A0DAFF64-97E0-49BF-94C7-110551C1B1B3}.Debug|x86.ActiveCfg = Debug|Win32
{A0DAFF64-97E0-49BF-94C7-110551C1B1B3}.Debug|x86.Build.0 = Debug|Win32
{A0DAFF64-97E0-49BF-94C7-110551C1B1B3}.Release|x64.ActiveCfg = Release|x64
{A0DAFF64-97E0-49BF-94C7-110551C1B1B3}.Release|x64.Build.0 = Release|x64
{A0DAFF64-97E0-49BF-94C7-110551C1B1B3}.Release|x86.ActiveCfg = Release|Win32
{A0DAFF64-97E0-49BF-94C7-110551C1B1B3}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1FBC48F3-4A7A-46B9-A3DD-A7FF608CDA75}
EndGlobalSection
EndGlobal
94 changes: 94 additions & 0 deletions mjjm3/Cal/Cal/Cal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@


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

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

using namespace std;

Calculator::Calculator() {}

string Calculator::MakeFormula() {
string formula = "";

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) {
double num = 0;
for (int i = 0; i < formula.length();) {
bool plus = true;
if (i != 0) {
plus = formula[i++] == '+';
}
int start = i;
while (isdigit(formula[i])) {
i++;
}
double tmp = stoi(formula.substr(start, i));
while (i < formula.length() && (formula[i] == '*' || formula[i] == '/')) {
char op = formula[i++];

int start = i;
while (isdigit(formula[i])) {
i++;
}
if (op == '*') {
tmp = tmp * stoi(formula.substr(start, i));
}
else {
tmp = tmp / stoi(formula.substr(start, i));
}

}
if (tmp - (int)tmp != 0) {
return "";
}
if (plus) {
num = num + tmp;
}
else {
num = num - tmp;
}

}
return formula + "=" + to_string((int)num);
}

int main()
{
Calculator* calc = new Calculator();
int n;
cin >> n;
ofstream file;
file.open("subject.txt");
for (int i = 0; i < n; i++) {
string question = calc->MakeFormula();
string ret = calc->Solve(question);
if (ret == "") {
i--;
continue;
}
file << ret << endl;
}
}



162 changes: 162 additions & 0 deletions mjjm3/Cal/Cal/Cal.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{F46B48A6-B8B7-4E00-87D9-252FB365A170}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Cal</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Cal.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Calculator.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
27 changes: 27 additions & 0 deletions mjjm3/Cal/Cal/Cal.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Cal.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Calculator.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions mjjm3/Cal/Cal/Cal.vcxproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
17 changes: 17 additions & 0 deletions mjjm3/Cal/Cal/Calculator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
#include <stack>
#include <vector>
#include <iostream>
#include "stdlib.h"
#include <ctime>
#include <string>
using namespace std;

class Calculator {
private:
string op[4] = { "+", "-", "*", "/" };
public:
Calculator();
string MakeFormula();
string Solve(string formula);
};
4 changes: 4 additions & 0 deletions mjjm3/Cal/Cal/Debug/Cal.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
 Cal.cpp
C:\Users\Shinelon\Desktop\Cal\Calculator\mjjm3\Cal\Cal\Cal.cpp(36,20): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\Shinelon\Desktop\Cal\Calculator\mjjm3\Cal\Cal\Cal.cpp(46,12): warning C4018: “<”: 有符号/无符号不匹配
Cal.vcxproj -> C:\Users\Shinelon\Desktop\Cal\Calculator\mjjm3\Cal\Debug\Cal.exe
Binary file added mjjm3/Cal/Cal/Debug/Cal.tlog/CL.command.1.tlog
Binary file not shown.
Binary file added mjjm3/Cal/Cal/Debug/Cal.tlog/CL.read.1.tlog
Binary file not shown.
Binary file added mjjm3/Cal/Cal/Debug/Cal.tlog/CL.write.1.tlog
Binary file not shown.
2 changes: 2 additions & 0 deletions mjjm3/Cal/Cal/Debug/Cal.tlog/Cal.lastbuildstate
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0
Debug|Win32|C:\Users\Shinelon\Desktop\Cal\Calculator\mjjm3\Cal\|
Binary file added mjjm3/Cal/Cal/Debug/Cal.tlog/link.command.1.tlog
Binary file not shown.
Binary file added mjjm3/Cal/Cal/Debug/Cal.tlog/link.read.1.tlog
Binary file not shown.
Binary file added mjjm3/Cal/Cal/Debug/Cal.tlog/link.write.1.tlog
Binary file not shown.
Binary file added mjjm3/Cal/Cal/Debug/cal.obj.enc
Binary file not shown.
Binary file added mjjm3/Cal/Cal/Debug/vc142.idb
Binary file not shown.
Binary file added mjjm3/Cal/Cal/Debug/vc142.pdb
Binary file not shown.
Loading