Archived
1
0
This commit is contained in:
2025-11-01 08:20:49 +08:00
parent e0fbc20716
commit 6151e4f8c9
29 changed files with 1010 additions and 3 deletions

20
cs4/CPP5/CPP5.cpp Normal file
View File

@@ -0,0 +1,20 @@
// CPP5.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件

31
cs4/CPP5/CPP5.sln Normal file
View File

@@ -0,0 +1,31 @@
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("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CPP5", "CPP5.vcxproj", "{D3103D25-0742-45FE-A6F9-07DDB00036AA}"
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
{D3103D25-0742-45FE-A6F9-07DDB00036AA}.Debug|x64.ActiveCfg = Debug|x64
{D3103D25-0742-45FE-A6F9-07DDB00036AA}.Debug|x64.Build.0 = Debug|x64
{D3103D25-0742-45FE-A6F9-07DDB00036AA}.Debug|x86.ActiveCfg = Debug|Win32
{D3103D25-0742-45FE-A6F9-07DDB00036AA}.Debug|x86.Build.0 = Debug|Win32
{D3103D25-0742-45FE-A6F9-07DDB00036AA}.Release|x64.ActiveCfg = Release|x64
{D3103D25-0742-45FE-A6F9-07DDB00036AA}.Release|x64.Build.0 = Release|x64
{D3103D25-0742-45FE-A6F9-07DDB00036AA}.Release|x86.ActiveCfg = Release|Win32
{D3103D25-0742-45FE-A6F9-07DDB00036AA}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2A3D6FB2-8224-4762-B411-D3B887B40C40}
EndGlobalSection
EndGlobal

131
cs4/CPP5/CPP5.vcxproj Normal file
View File

@@ -0,0 +1,131 @@
<?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>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{d3103d25-0742-45fe-a6f9-07ddb00036aa}</ProjectGuid>
<RootNamespace>CPP5</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>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</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" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<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)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<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|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="CPP5.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@
<?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;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;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="CPP5.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

10
cs4/CS4_1/CS4_1.csproj Normal file
View File

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

25
cs4/CS4_1/CS4_1.sln Normal file
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}") = "CS4_1", "CS4_1.csproj", "{176395D4-286A-4CFB-8CA6-ABB8FC8E2144}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{176395D4-286A-4CFB-8CA6-ABB8FC8E2144}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{176395D4-286A-4CFB-8CA6-ABB8FC8E2144}.Debug|Any CPU.Build.0 = Debug|Any CPU
{176395D4-286A-4CFB-8CA6-ABB8FC8E2144}.Release|Any CPU.ActiveCfg = Release|Any CPU
{176395D4-286A-4CFB-8CA6-ABB8FC8E2144}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9BE27323-1DB1-4334-A15D-B183D58010C3}
EndGlobalSection
EndGlobal

52
cs4/CS4_1/Program.cs Normal file
View File

@@ -0,0 +1,52 @@
using System;
namespace CS4_1
{
public class Program
{
static void Main(string[] args)
{
int min, max, sum = 0, average;
int[] A = new int[10];
Random rand = new Random();
for (int i = 0; i < A.Length; i++)
{
A[i] = rand.Next(1, 101);
}
Console.WriteLine("原始数组为:");
foreach (var item in A)
{
Console.Write("{0,4}", item);
}
min = max = A[0];
for (int i = 0; i < A.Length; i++)
{
if (A[i] < min) min = A[i];
if (A[i] > max) max = A[i];
sum += A[i];
}
average = sum / A.Length;
Console.WriteLine("\n数组的最小值为{0}", min);
Console.WriteLine("数组的最大值为:{0}", max);
Console.WriteLine("数组的平均值为:{0}", average);
// 元素降序排序
int n = A.Length;
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < n - 1 - i; j++)
{
if (A[j] < A[j + 1])
{
int temp = A[j];
A[j] = A[j + 1];
A[j + 1] = temp;
}
}
}
Console.WriteLine("数组元素降序排序后为:");
foreach (var item in A)
{
Console.Write("{0,4}", item);
}
}
}
}

10
cs4/CS4_2/CS4_2.csproj Normal file
View File

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

25
cs4/CS4_2/CS4_2.sln Normal file
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}") = "CS4_2", "CS4_2.csproj", "{D2BA0541-32E9-4C7D-AE89-9E7B7B49969C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D2BA0541-32E9-4C7D-AE89-9E7B7B49969C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2BA0541-32E9-4C7D-AE89-9E7B7B49969C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2BA0541-32E9-4C7D-AE89-9E7B7B49969C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2BA0541-32E9-4C7D-AE89-9E7B7B49969C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9CC792AC-CC4E-4F02-B199-034BABCE42D4}
EndGlobalSection
EndGlobal

36
cs4/CS4_2/Program.cs Normal file
View File

@@ -0,0 +1,36 @@
using System;
namespace CS4_2
{
public class Program
{
static void Main(string[] args)
{
int[] score = { 80, 90, 67, 89, 78, 85, 45, 65, 77, 95 };
// 统计分数段
int a = 0, b = 0, c = 0, d = 0;
for (int i = 0; i < score.Length; i++)
{
if (score[i] >= 90)
{
a++;
}
else if (score[i] >= 80)
{
b++;
}
else if (score[i] >= 60)
{
c++;
}
else
{
d++;
}
}
Console.WriteLine("90分及以上人数" + a);
Console.WriteLine("80-89分人数" + b);
Console.WriteLine("60-79分人数" + c);
Console.WriteLine("60分以下人数" + d);
}
}
}

10
cs4/CS4_3/CS4_3.csproj Normal file
View File

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

25
cs4/CS4_3/CS4_3.sln Normal file
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}") = "CS4_3", "CS4_3.csproj", "{FCCD1D8D-1B13-483D-837B-FBB41A496BCD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FCCD1D8D-1B13-483D-837B-FBB41A496BCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCCD1D8D-1B13-483D-837B-FBB41A496BCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCCD1D8D-1B13-483D-837B-FBB41A496BCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCCD1D8D-1B13-483D-837B-FBB41A496BCD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FCF021EF-C7A9-414B-ACEB-91F4122C1216}
EndGlobalSection
EndGlobal

40
cs4/CS4_3/Program.cs Normal file
View File

@@ -0,0 +1,40 @@
using System;
namespace CS4_3
{
public class Program
{
static void Main(string[] args)
{
int[] A = new int[10];
Random rand = new Random();
for (int i = 0; i < A.Length; i++)
{
A[i] = rand.Next(1, 999);
}
Console.WriteLine("原数组:");
for (int i = 0; i < A.Length; i++)
{
Console.Write(A[i] + " ");
}
// 冒泡排序
int temp;
for (int i = 0; i < A.Length - 1; i++)
{
for (int j = 0; j < A.Length - 1 - i; j++)
{
if (A[j] > A[j + 1])
{
temp = A[j];
A[j] = A[j + 1];
A[j + 1] = temp;
}
}
}
Console.WriteLine("\n排序后数组");
for (int i = 0; i < A.Length; i++)
{
Console.Write(A[i] + " ");
}
}
}
}