Skip to content
Open
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
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
31 changes: 31 additions & 0 deletions dwyy666/Calculator1/Calculator1.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2042
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Calculator1", "Calculator1\Calculator1.csproj", "{4B9826EA-B6F6-41F3-8B91-83491A6EEA18}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject1", "UnitTestProject1\UnitTestProject1.csproj", "{487C3A96-7E19-4D6F-B320-5C0422E0FEF2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4B9826EA-B6F6-41F3-8B91-83491A6EEA18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4B9826EA-B6F6-41F3-8B91-83491A6EEA18}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B9826EA-B6F6-41F3-8B91-83491A6EEA18}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B9826EA-B6F6-41F3-8B91-83491A6EEA18}.Release|Any CPU.Build.0 = Release|Any CPU
{487C3A96-7E19-4D6F-B320-5C0422E0FEF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{487C3A96-7E19-4D6F-B320-5C0422E0FEF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{487C3A96-7E19-4D6F-B320-5C0422E0FEF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{487C3A96-7E19-4D6F-B320-5C0422E0FEF2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1DDE5903-3608-4D65-8D90-26DD6D7B3BD4}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions dwyy666/Calculator1/Calculator1/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
</configuration>
54 changes: 54 additions & 0 deletions dwyy666/Calculator1/Calculator1/Calculator1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4B9826EA-B6F6-41F3-8B91-83491A6EEA18}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Calculator1</RootNamespace>
<AssemblyName>Calculator1</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="getNum.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="writeFile.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
39 changes: 39 additions & 0 deletions dwyy666/Calculator1/Calculator1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Calculator1
{
class Program
{
static void Main(string[] args)
{
Console.Write("请输入出题个数:");
int n = Convert.ToInt32(Console.ReadLine());
int i = 0;
object result;
DataTable dt = new DataTable();
while (i < n)
{
getNum getnum1 = new getNum();

String str = getnum1.getnum();
result = dt.Compute(str, "");
//如果结果含有小数点,或者表达式中有除以0,或者结果为负数则再次获取一个计算式
if (result.ToString().Contains(".") || str.Contains("/0") || int.Parse(result.ToString()) < 0)
continue;
i++;
string str1;
str1 = str.Replace("/", "÷") + "=" + result.ToString();
Console.WriteLine(str1);
writeFile writefile1 = new writeFile();
writefile1.writefile(str1);
}
//System.Threading.Thread.Sleep(10000);
}
}
}
36 changes: 36 additions & 0 deletions dwyy666/Calculator1/Calculator1/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Calculator1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Calculator1")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]

// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("4b9826ea-b6f6-41f3-8b91-83491a6eea18")]

// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
33 changes: 33 additions & 0 deletions dwyy666/Calculator1/Calculator1/getNum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Calculator1
{
class getNum
{
private static char[] size = { '+', '-', '*', '/' };
public string getnum()
{
int x, y, z, t;

Random random = new Random();
z = random.Next(2, 4);//作为随机运算符个数

string str;
x = random.Next(0, 100);//作为随机数值
str = Convert.ToString(x);

for (int i = 0; i < z; i++)
{
t = random.Next(0, 4);//作为随机运算符下标
y = random.Next(0, 100);
str += size[t] + Convert.ToString(y);//拼接字符串
System.Threading.Thread.Sleep(50);//由于时间间隔太短,需要设置程序睡眠
}
return str;
}
}
}
29 changes: 29 additions & 0 deletions dwyy666/Calculator1/Calculator1/writeFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Calculator1
{
public class writeFile
{
public void writefile(string str)
{

try
{
StreamWriter sw = new StreamWriter("e:\\test.txt", true);
sw.WriteLine(str);
sw.Close();
}
catch (Exception e)
{
Console.WriteLine("文件写入失败!");
}


}
}
}
20 changes: 20 additions & 0 deletions dwyy666/Calculator1/UnitTestProject1/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("UnitTestProject1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UnitTestProject1")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("487c3a96-7e19-4d6f-b320-5c0422e0fef2")]

// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
19 changes: 19 additions & 0 deletions dwyy666/Calculator1/UnitTestProject1/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Calculator1;
namespace UnitTestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
string str = "16*3+2*1=50";
writeFile file = new writeFile();
file.writefile(str);
string txt = System.IO.File.ReadAllText(@"e:\\test.txt");
Assert.IsTrue(txt == str);
}
}
}
Loading