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

View File

@@ -96,8 +96,8 @@ int PrintList(LinkList L)
int main() int main()
{ {
LinkList bss1, bss2, bss3; LinkList bss1, bss2, bss3;
int A[] = { 958,599,9485,95626,989923 }; int A[] = { 253,342,465,586,678 };
int B[] = { 3155,78,9623,7265,98630,983266 }; int B[] = { 787,895,996,1023,2096,3323 };
CreatList(bss1, 5, A); CreatList(bss1, 5, A);
CreatList(bss2, 6, B); CreatList(bss2, 6, B);
printf("第一个链表: \n"); printf("第一个链表: \n");

112
CPP2/作业二.cpp Normal file
View File

@@ -0,0 +1,112 @@
#include<stdio.h>
#include<stdlib.h>
#define ElemType int
#define OK 1
#define OVERFLOW 0
// 链表定义
typedef struct LNode{
ElemType data;
struct LNode* next;
} LNode, * LinkList;
// 初始化链表
int InitList(LinkList &L){
L = (LNode*)malloc(sizeof(LNode));
if (!L) return OVERFLOW;
L->next = NULL;
return OK;
}
// 生成新节点
LNode* MakeNode(ElemType e) {
LNode* bss;
bss = (LNode*)malloc(sizeof(LNode));
if (bss != NULL) {
bss->data = e;
bss->next = NULL;
}
return bss;
}
// 插入节点
int Insert(LinkList &L, LNode* s){
if (!L) return OVERFLOW;
s->next = L->next;
L->next = s;
return OK;
}
// 创建链表
int CreatList(LinkList& L, int n, ElemType A[]){
LNode* p, * q;
int i;
if (!InitList(L)) return OVERFLOW;
p = L;
for (i = 0; i < n; i++)
{
q = MakeNode(A[i]);
Insert(p, q);
p = q;
}
return OK;
}
// 合并链表
int MergeList(LinkList La, LinkList Lb, LinkList& Lc)
{
LNode* pa, * pb, * pc;
pa = La->next;
pb = Lb->next;
if (!InitList(Lc)) return OVERFLOW;
pc = Lc;
while (pa && pb)
{
if (pa->data <= pb->data)
{
pc->next = pa;
pc = pa;
pa = pa->next;
}
else
{
pc->next = pb;
pc = pb;
pb = pb->next;
}
}
pc->next = pa ? pa : pb;
return OK;
}
// 打印链表
int PrintList(LinkList L)
{
LNode* p = L->next;
while (p)
{
printf("%d ", p->data);
p = p->next;
}
printf("\n");
return OK;
}
int main()
{
LinkList bss1, bss2, bss3;
int A[] = { 253,342,465,586,678 };
int B[] = { 787,895,996,1023,2096,3323 };
CreatList(bss1, 5, A);
CreatList(bss2, 6, B);
printf("第一个链表: \n");
PrintList(bss1);
printf("第二个链表: \n");
PrintList(bss2);
MergeList(bss1, bss2, bss3);
printf("合并后的链表: \n");
PrintList(bss3);
return 0;
}

93
CPP4/CPP4.cpp Normal file
View File

@@ -0,0 +1,93 @@
#include <stdio.h>
#include <stdlib.h>
#define Type int
// 定义哈希表
typedef struct HashTable {
Type* table;
int Length;
} HashTable;
// 哈希函数
int HashFunction(HashTable &HashTable,int key) {
return key % HashTable.Length;
}
// 初始化哈希表
void initHashTable(HashTable &HashTable) {
HashTable.table = (Type*)malloc(HashTable.Length * sizeof(Type));
for (int i = 0; i < HashTable.Length; i++) {
HashTable.table[i] = -1;
}
}
// 线性探测再散列
void insert1(HashTable &HashTable, int key) {
int index = HashFunction(HashTable, key);
while (HashTable.table[index] != -1) {
index = (index + 1) % HashTable.Length;
}
HashTable.table[index] = key;
}
// 二次探测再散列
void insert2(HashTable& HashTable, int key) {
int index = HashFunction(HashTable, key);
if (HashTable.table[index] == -1) {
HashTable.table[index] = key;
return;
}
for (int i = 1; i < HashTable.Length; ++i) {
int sign = (i & 1) ? 1 : -1;
int sq = (i + 1) / 2;
int d = sign * sq * sq;
int position = (index + d) % HashTable.Length;
if (position < 0) position += HashTable.Length;
if (HashTable.table[position] == -1) {
HashTable.table[position] = key;
return;
}
}
}
// 打印哈希表
void printHashTable(HashTable &HashTable) {
for (int i = 0; i < HashTable.Length; i++) {
if (HashTable.table[i] == -1) {
printf("");
}
else {
printf("%d ", HashTable.table[i]);
}
}
}
int main()
{
HashTable HashTable1, HashTable2;
HashTable1.Length = 11;
HashTable2.Length = 11;
initHashTable(HashTable1);
initHashTable(HashTable2);
int keys[] = { 19, 1, 23, 14, 55, 68, 11, 82, 36 };
int n = sizeof(keys) / sizeof(keys[0]);
for (int i = 0; i < n; i++) {
insert1(HashTable1, keys[i]);
}
for (int i = 0; i < n; i++) {
insert2(HashTable2, keys[i]);
}
// 打印哈希表
printf("线性探测再散列结果:\n");
printHashTable(HashTable1);
printf("\n");
printf("二次探测再散列结果:\n");
printHashTable(HashTable2);
return 0;
}

31
CPP4/CPP4.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}") = "CPP4", "CPP4.vcxproj", "{3E1258FB-07C6-41FC-AA54-03A983857CDE}"
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
{3E1258FB-07C6-41FC-AA54-03A983857CDE}.Debug|x64.ActiveCfg = Debug|x64
{3E1258FB-07C6-41FC-AA54-03A983857CDE}.Debug|x64.Build.0 = Debug|x64
{3E1258FB-07C6-41FC-AA54-03A983857CDE}.Debug|x86.ActiveCfg = Debug|Win32
{3E1258FB-07C6-41FC-AA54-03A983857CDE}.Debug|x86.Build.0 = Debug|Win32
{3E1258FB-07C6-41FC-AA54-03A983857CDE}.Release|x64.ActiveCfg = Release|x64
{3E1258FB-07C6-41FC-AA54-03A983857CDE}.Release|x64.Build.0 = Release|x64
{3E1258FB-07C6-41FC-AA54-03A983857CDE}.Release|x86.ActiveCfg = Release|Win32
{3E1258FB-07C6-41FC-AA54-03A983857CDE}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {10EDD9F8-190F-4596-ADAB-DBE0E5F185FC}
EndGlobalSection
EndGlobal

131
CPP4/CPP4.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>{3e1258fb-07c6-41fc-aa54-03a983857cde}</ProjectGuid>
<RootNamespace>CPP4</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="CPP4.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

22
CPP4/CPP4.vcxproj.filters Normal file
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="CPP4.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -1,4 +1,5 @@
namespace C_Sharp_3_5 using System;
namespace C_Sharp_3_5
{ {
internal class Program internal class Program
{ {

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] + " ");
}
}
}
}

11
cs5/5_1/5_1.csproj Normal file
View File

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

25
cs5/5_1/5_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}") = "5_1", "5_1.csproj", "{82D15861-AC86-4C64-8477-2687C2846721}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{82D15861-AC86-4C64-8477-2687C2846721}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82D15861-AC86-4C64-8477-2687C2846721}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82D15861-AC86-4C64-8477-2687C2846721}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82D15861-AC86-4C64-8477-2687C2846721}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {65D009ED-CB3D-43A5-98F3-0FD1FFFBF78E}
EndGlobalSection
EndGlobal

34
cs5/5_1/Program.cs Normal file
View File

@@ -0,0 +1,34 @@
using System;
namespace _5_1
{
class MyMath
{
public const double PI = 3.1415926;
public static double perimeter(double r)
{
double p = 2 * PI * r;
return p;
}
public static double area(double r)
{
double a = PI * r * r;
return a;
}
public static double volume(double r)
{
double v = (4.0 / 3) * PI * r * r * r;
return v;
}
public class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入半径:\n");
double r = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("圆的周长为:{0}\n", MyMath.perimeter(r));
Console.WriteLine("圆的面积为:{0}\n", MyMath.area(r));
Console.WriteLine("球的体积为:{0}\n", MyMath.volume(r));
}
}
}
}

11
cs5/5_2/5_2.csproj Normal file
View File

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

25
cs5/5_2/5_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}") = "5_2", "5_2.csproj", "{24FDF2F6-69DD-4F6F-A667-8EE25A8F65D8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{24FDF2F6-69DD-4F6F-A667-8EE25A8F65D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{24FDF2F6-69DD-4F6F-A667-8EE25A8F65D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24FDF2F6-69DD-4F6F-A667-8EE25A8F65D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24FDF2F6-69DD-4F6F-A667-8EE25A8F65D8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0F9A79BA-C7F0-4698-B7CC-C8889EA6B5FE}
EndGlobalSection
EndGlobal

28
cs5/5_2/Program.cs Normal file
View File

@@ -0,0 +1,28 @@
using System;
namespace _5_2
{
public class TemperatureCelius
{
private double degree;
public TemperatureCelius(double degree)
{
this.degree = degree;
}
public double toFahrenheit()
{
return (degree * 9 / 5) + 32;
}
}
public class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入摄氏温度:\n");
double celsius = Convert.ToDouble(Console.ReadLine());
TemperatureCelius tempCelius = new TemperatureCelius(celsius);
double fahrenheit = tempCelius.toFahrenheit();
Console.WriteLine("对应的华氏温度是:{0}\n", fahrenheit);
Console.ReadKey();
}
}
}

11
cs5/5_3/5_3.csproj Normal file
View File

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

25
cs5/5_3/5_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}") = "5_3", "5_3.csproj", "{32BEEF67-DFCA-4551-90C6-9DC2246E4FF9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{32BEEF67-DFCA-4551-90C6-9DC2246E4FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32BEEF67-DFCA-4551-90C6-9DC2246E4FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32BEEF67-DFCA-4551-90C6-9DC2246E4FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32BEEF67-DFCA-4551-90C6-9DC2246E4FF9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9CE2E177-5663-42F5-9B3C-BD782E54D2D4}
EndGlobalSection
EndGlobal

10
cs5/5_3/Program.cs Normal file
View File

@@ -0,0 +1,10 @@
namespace _5_3
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}