1
This commit is contained in:
@@ -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>
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user