Archived
1
0
This commit is contained in:
2025-10-24 17:20:56 +08:00
parent acc0c9e220
commit e0fbc20716
21 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36616.10 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C Sharp 1_1", "C Sharp 1_1.csproj", "{C2EC9237-9D92-490E-8A85-9727DF433991}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C2EC9237-9D92-490E-8A85-9727DF433991}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2EC9237-9D92-490E-8A85-9727DF433991}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2EC9237-9D92-490E-8A85-9727DF433991}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2EC9237-9D92-490E-8A85-9727DF433991}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CE7B74FA-2C51-4DEE-97D7-7D0DB5455A3C}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>C_Sharp_1</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

19
cs1/C Sharp 1/Program.cs Normal file
View File

@@ -0,0 +1,19 @@
using System;
using static System.Math;
namespace C_Sharp_1
{
public class Program
{
static void Main(string[] args)
{
double r, c, s, v;
Console.WriteLine("请输入半径:");
r = double.Parse(Console.ReadLine());
c = 2 * PI * r;
s = PI * Pow(r, 2);
v = (4 / 3.0) * PI * Pow(r, 3);
Console.WriteLine("圆周长为{0},面积为{1}",c,s);
Console.WriteLine("球体积为{0}", v);
}
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>C_Sharp_1_2</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36616.10 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C Sharp 1_2", "C Sharp 1_2.csproj", "{8832C7BB-57A7-443D-BE9A-0666612F71AA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8832C7BB-57A7-443D-BE9A-0666612F71AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8832C7BB-57A7-443D-BE9A-0666612F71AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8832C7BB-57A7-443D-BE9A-0666612F71AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8832C7BB-57A7-443D-BE9A-0666612F71AA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {30FC1B92-3A5C-409D-8B1F-141D6ED8F503}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,29 @@
using System;
namespace C_Sharp_1_2
{
public class Program
{
static void Main(string[] args)
{
Console.Write("请输入三角形的边长a");
double a = double.Parse(Console.ReadLine());
Console.Write("请输入三角形的边长b");
double b = double.Parse(Console.ReadLine());
Console.Write("请输入三角形的边长c");
double c = double.Parse(Console.ReadLine());
if (a + b > c && a + c > b && b + c > a)
{
double perimeter = a + b + c;
double s = (a + b + c) / 2;
double area = Math.Sqrt(s * (s - a) * (s - b) * (s - c));
Console.WriteLine("三角形的三边长为a={0}b={1}c={2}", a, b, c);
Console.WriteLine("三角形的周长为{0},面积为:{1}",perimeter,area);
}
else
{
Console.WriteLine("输入的边长不能构成三角形。");
}
Console.ReadLine();
}
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>C_Sharp_1_3</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36616.10 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C Sharp 1_3", "C Sharp 1_3.csproj", "{F4C49F99-3163-4F59-A9C9-DE459FA38244}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F4C49F99-3163-4F59-A9C9-DE459FA38244}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4C49F99-3163-4F59-A9C9-DE459FA38244}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4C49F99-3163-4F59-A9C9-DE459FA38244}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4C49F99-3163-4F59-A9C9-DE459FA38244}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ED18AC2B-9EF6-468F-ACCB-466A5CF892F1}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,47 @@
using System;
using static System.Math;
namespace C_Sharp_1_3
{
public class Program
{
static void Main()
{
Console.WriteLine("请输入变量x的值");
double x = double.Parse(Console.ReadLine());
double y;
// 单句单分支方法
y = Log(-5 * x) + 6 * Sqrt(Abs(x) + Exp(4)) - Pow((x + 1), 3);
if (x>=0)
{
y = (Pow(x, 2) - 3 * x) / (Pow(x, 2) + 1) + 2 * PI + Sin(x);
}
Console.WriteLine("方法一x={0},y={1}",x,y);
// 两句单分支方法
if (x >= 0)
{
y = (Pow(x, 2) - 3 * x) / (Pow(x, 2) + 1) + 2 * PI + Sin(x);
}
if(x < 0)
{
y = Log(-5 * x) + 6 * Sqrt(Abs(x) + Exp(4)) - Pow((x + 1), 3);
}
Console.WriteLine("方法二x={0},y={1}", x,y);
// 双分支方法
if (x >= 0)
{
y = (Pow(x, 2) - 3 * x) / (Pow(x, 2) + 1) + 2 * PI + Sin(x);
}
else
{
y = Log(-5 * x) + 6 * Sqrt(Abs(x) + Exp(4)) - Pow((x + 1), 3);
}
Console.WriteLine("方法三x={0},y={1}",x,y);
// 条件运算符方法
y = (x >= 0) ? (Pow(x, 2) - 3 * x) / (Pow(x, 2) + 1) + 2 * PI + Sin(x) : Log(-5 * x) + 6 * Sqrt(Abs(x) + Exp(4)) - Pow((x + 1), 3);
Console.WriteLine("方法四x={0},y={1}",x,y);
}
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>C_Sharp_1_4</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36616.10 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C Sharp 1_4", "C Sharp 1_4.csproj", "{BD4BE51C-6BCA-47CD-813F-0BF6B3F0F932}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BD4BE51C-6BCA-47CD-813F-0BF6B3F0F932}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD4BE51C-6BCA-47CD-813F-0BF6B3F0F932}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD4BE51C-6BCA-47CD-813F-0BF6B3F0F932}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD4BE51C-6BCA-47CD-813F-0BF6B3F0F932}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3117BDA3-B16F-41AF-91D3-39E71330CCD4}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,39 @@
using System;
using static System.Math;
namespace C_Sharp_1_4
{
public class Program
{
static void Main()
{
int a, b, c, a1, b1, c1, temp, max, min, medium;
Random rNumber = new Random();
a = rNumber.Next(101);
b = rNumber.Next(101);
c = rNumber.Next(101);
a1 = a; b1 = b; c1 = c;
Console.WriteLine("原始值: a={0}, b={1}, c={2}");
// 方法一
if (a > b)
{
temp = a; a = b; b = temp;
}
if (a > c)
{
temp = a; a = c; c = temp;
}
if (b > c)
{
temp = b; b = c; c = temp;
}
Console.WriteLine("第一种方法排序: a={0}, b={1}, c={2}", a, b, c);
// 方法二
a = a1; b = b1; c = c1;
max = Max(a, Max(b, c));
min = Min(a, Min(b, c));
medium = a + b + c - max - min;
Console.WriteLine("第二种方法排序: a={0}, b={1}, c={2}", min, medium, max);
}
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>C_Sharp_1_5</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36616.10 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C Sharp 1_5", "C Sharp 1_5.csproj", "{F61264D6-1D87-49B4-95DE-DE6F15D87093}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F61264D6-1D87-49B4-95DE-DE6F15D87093}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F61264D6-1D87-49B4-95DE-DE6F15D87093}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F61264D6-1D87-49B4-95DE-DE6F15D87093}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F61264D6-1D87-49B4-95DE-DE6F15D87093}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5C19FCB6-F862-406A-828F-804B5E63FE05}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,44 @@
using System;
using static System.Math;
namespace C_Sharp_1_5
{
public class Program
{
static void Main()
{
double a, b, c, delta, real, imag;
Console.Write("请输入系数a");
a = double.Parse(Console.ReadLine());
Console.Write("请输入系数b");
b = double.Parse(Console.ReadLine());
Console.Write("请输入系数c");
c = double.Parse(Console.ReadLine());
if (a == 0 && b == 0)
{
Console.WriteLine("该方程无解");
}
else
{
delta = b * b - 4 * a * c;
if (delta > 0)
{
double x1 = (-b + Sqrt(delta)) / (2 * a);
double x2 = (-b - Sqrt(delta)) / (2 * a);
Console.WriteLine("该方程有两个不等实根分别为x1={0},x2={1}", x1, x2);
}
else if (delta == 0)
{
double x = -b / (2 * a);
Console.WriteLine("该方程有两个相等实根均为x={0}", x);
}
else
{
real = -b / (2 * a);
imag = Sqrt(-delta) / (2 * a);
Console.WriteLine("该方程有两个共轭复根分别为x1={0}+{1}i,x2={0}-{1}i", real, imag);
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>C_Sharp_1_6</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36616.10 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C Sharp 1_6", "C Sharp 1_6.csproj", "{AF3388D7-450E-45A7-937A-E0E25B121BBF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AF3388D7-450E-45A7-937A-E0E25B121BBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF3388D7-450E-45A7-937A-E0E25B121BBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF3388D7-450E-45A7-937A-E0E25B121BBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF3388D7-450E-45A7-937A-E0E25B121BBF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AAF2189D-E99F-407F-BB12-C4BE6849EE5E}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,42 @@
using System.Diagnostics;
namespace C_Sharp_1_6
{
public class Program
{
static void Main(string[] args)
{
int i;
Console.WriteLine("请输入一个代表星期的数字");
i = int.Parse(Console.ReadLine());
switch (i)
{
case 1:
Console.WriteLine("星期一");
break;
case 2:
Console.WriteLine("星期二");
break;
case 3:
Console.WriteLine("星期三");
break;
case 4:
Console.WriteLine("星期四");
break;
case 5:
Console.WriteLine("星期五");
break;
case 6:
Console.WriteLine("星期六");
break;
case 7:
Console.WriteLine("星期日");
break;
default:
Console.WriteLine("输入错误");
break;
}
}
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>C_Sharp_1_7</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36616.10 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C Sharp 1_7", "C Sharp 1_7.csproj", "{1D496A2B-B515-47C2-92E5-DA4E71E6241D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1D496A2B-B515-47C2-92E5-DA4E71E6241D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D496A2B-B515-47C2-92E5-DA4E71E6241D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D496A2B-B515-47C2-92E5-DA4E71E6241D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D496A2B-B515-47C2-92E5-DA4E71E6241D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {91D75058-A649-4AB6-831D-FD35895D09FB}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,24 @@
using System;
namespace C_Sharp_1_7
{
public class Program
{
static void Main(string[] args)
{
double salary, fees;
Console.WriteLine("请输入工资");
salary = double.Parse(Console.ReadLine());
if (salary > 0 && salary <= 3000)
fees = salary * 0.0005;
else if (salary > 3000 && salary <= 5000)
fees = salary * 0.0010;
else if (salary > 5000 && salary <= 10000)
fees = salary * 0.0015;
else if (salary > 10000)
fees = salary * 0.0020;
else
Console.WriteLine("工资输入有误");
Console.WriteLine("应缴纳的费用是:" + fees);
}
}
}