diff --git a/15.1/15.1.csproj b/15.1/15.1.csproj new file mode 100644 index 0000000..b96ef59 --- /dev/null +++ b/15.1/15.1.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _15._1 + enable + enable + + + diff --git a/15.1/15.1.sln b/15.1/15.1.sln new file mode 100644 index 0000000..3eaf123 --- /dev/null +++ b/15.1/15.1.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "15.1", "15.1.csproj", "{816086E8-93CF-41C4-8DC4-EE4B44FE918B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {816086E8-93CF-41C4-8DC4-EE4B44FE918B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {816086E8-93CF-41C4-8DC4-EE4B44FE918B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {816086E8-93CF-41C4-8DC4-EE4B44FE918B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {816086E8-93CF-41C4-8DC4-EE4B44FE918B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F6856EF0-4074-451B-9ED7-D1F4FC4E61BD} + EndGlobalSection +EndGlobal diff --git a/15.1/Program.cs b/15.1/Program.cs new file mode 100644 index 0000000..3ea04a0 --- /dev/null +++ b/15.1/Program.cs @@ -0,0 +1,54 @@ +using System; +using System.Drawing; +namespace _15._1 +{ + class MathTriangle + { + private double sideA; + private double sideB; + private double sideC; + public MathTriangle(double a, double b, double c) + { + sideA = Math.Abs(a); + sideB = Math.Abs(b); + sideC = Math.Abs(c); + } + public double GetArea() + { + double s = (sideA + sideB + sideC) / 2; + return Math.Sqrt(s * (s - sideA) * (s - sideB) * (s - sideC)); + } + public double GetPerimeter() + { + return sideA + sideB + sideC; + } + public double GetHeight() + { + double area = GetArea(); + return (2 * area) / sideA; + } + public double GetMaxSide() + { + return Math.Max(sideA, Math.Max(sideB, sideC)); + } + public double GetMinSide() + { + return Math.Min(sideA, Math.Min(sideB, sideC)); + } + private double GetPartSideA() + { + return Math.Sqrt((Math.Pow(sideB, 2.0) - Math.Pow(GetHeight(), 2.0))); + + } + static void Main() + { + MathTriangle triangle = new MathTriangle(16.0, 10.0, 8.0); + Console.WriteLine("三角形三边长分别为: {0}, {1}, {2}", triangle.sideA, triangle.sideB, triangle.sideC); + Console.WriteLine("三角形的面积为: {0:#.00}", triangle.GetArea()); + Console.WriteLine("三角形的周长为: {0}", triangle.GetPerimeter()); + Console.WriteLine("三角形的A边高为: {0:#.00}", triangle.GetHeight()); + Console.WriteLine("三角形的最大边为: {0}", triangle.GetMaxSide()); + Console.WriteLine("三角形的最小边为: {0}", triangle.GetMinSide()); + } + } +} diff --git a/15.2/15.2.csproj b/15.2/15.2.csproj new file mode 100644 index 0000000..1b290db --- /dev/null +++ b/15.2/15.2.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _15._2 + enable + enable + + + diff --git a/15.2/15.2.sln b/15.2/15.2.sln new file mode 100644 index 0000000..958fb3b --- /dev/null +++ b/15.2/15.2.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "15.2", "15.2.csproj", "{19E0F84F-ABD6-4CA7-A1FE-ECFA8580D0CA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {19E0F84F-ABD6-4CA7-A1FE-ECFA8580D0CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19E0F84F-ABD6-4CA7-A1FE-ECFA8580D0CA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19E0F84F-ABD6-4CA7-A1FE-ECFA8580D0CA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19E0F84F-ABD6-4CA7-A1FE-ECFA8580D0CA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {99434B3A-CA5C-4FB3-AB1F-F7DA100B86A5} + EndGlobalSection +EndGlobal diff --git a/15.2/Program.cs b/15.2/Program.cs new file mode 100644 index 0000000..4fa34ac --- /dev/null +++ b/15.2/Program.cs @@ -0,0 +1,30 @@ +using System; +using System.Threading; + +namespace _15._2 +{ + public class RandomObjectDemo + { + static void RunIntRan(Random randObj) + { + for (int i = 0; i < 6; i++) + { + Console.Write("{0,10}", randObj.Next()); + } + for (int i = 0;i < 6; i++) + { + Console.Write('{1,10}',randObj.NextDouble()); + } + } + static void Fixseed(Random randObj) + { + Random fixseed = new Random(); + fixseed.Next(); + } + static void autoseed() + { + Thread.Sleep(1); + Console.WriteLine("时间"); + } + } +} diff --git a/15.3/15.3.csproj b/15.3/15.3.csproj new file mode 100644 index 0000000..995ce7b --- /dev/null +++ b/15.3/15.3.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _15._3 + enable + enable + + + diff --git a/15.3/15.3.sln b/15.3/15.3.sln new file mode 100644 index 0000000..5e3a1fb --- /dev/null +++ b/15.3/15.3.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "15.3", "15.3.csproj", "{9E5AF88C-21DA-425C-A729-EF94F8612EBA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9E5AF88C-21DA-425C-A729-EF94F8612EBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E5AF88C-21DA-425C-A729-EF94F8612EBA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E5AF88C-21DA-425C-A729-EF94F8612EBA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E5AF88C-21DA-425C-A729-EF94F8612EBA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A401EAC7-95C0-4EE7-AACB-4DCF57437BA2} + EndGlobalSection +EndGlobal diff --git a/15.3/Program.cs b/15.3/Program.cs new file mode 100644 index 0000000..e644aac --- /dev/null +++ b/15.3/Program.cs @@ -0,0 +1,26 @@ +namespace _15._3 +{ + internal class Program + { + static void Main(string[] args) + { + const string s4 = " "; + int nYear = DateTime.Today.Year; + int nMonth = DateTime.Today.Month; + DateTime d1 = new DateTime(nYear, nMonth, 1); + Console.WriteLine("{0}/{1}", d1.Year, d1.Month); + Console.WriteLine("SUN MON TUE WED THU FRI SAT"); + int iWeek = (int)d1.DayOfWeek; + int iLastDay = d1.AddMonths(1).AddDays(-1).Day; + for (int i = 0; i < iWeek; i++) + { + Console.Write(s4); + } + for (int i = 1; i <= iLastDay; i++) + { + Console.Write(" {0:00} ", i); + if ((i + iWeek) % 7 == 0) Console.WriteLine(); + } + } + } +} diff --git a/15_4/15_4.csproj b/15_4/15_4.csproj new file mode 100644 index 0000000..84a2a48 --- /dev/null +++ b/15_4/15_4.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _15_4 + enable + enable + + + diff --git a/15_4/15_4.sln b/15_4/15_4.sln new file mode 100644 index 0000000..791fd56 --- /dev/null +++ b/15_4/15_4.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "15_4", "15_4.csproj", "{A5D84909-CEAE-418D-8431-F44DFC39C3AF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A5D84909-CEAE-418D-8431-F44DFC39C3AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5D84909-CEAE-418D-8431-F44DFC39C3AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5D84909-CEAE-418D-8431-F44DFC39C3AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5D84909-CEAE-418D-8431-F44DFC39C3AF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8D89CBFF-8DF9-4F24-8802-9BF5740164E4} + EndGlobalSection +EndGlobal diff --git a/15_4/Program.cs b/15_4/Program.cs new file mode 100644 index 0000000..d3cbf31 --- /dev/null +++ b/15_4/Program.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections; + +namespace _15_4 +{ + internal class Program + { + static void Main(string[] args) + { + int countA = 0, countE = 0, countI = 0, countO = 0, countU = 0, countALL = 0; + string str = Console.ReadLine(); + str = str.ToUpper(); + char[] chars = str.ToCharArray(); + foreach (char c in chars) + { + countALL++; + switch (c) + { + case 'A': countA++; break; + case 'E': countE++; break; + case 'I': countI++; break; + case 'O': countO++; break; + case 'U': countU++; break; + default: break; + } + } + Console.WriteLine(countALL); + Console.WriteLine(str); + Console.WriteLine("A:{0}", countA); + Console.WriteLine("E:{0}", countE); + Console.WriteLine("I:{0}", countI); + Console.WriteLine("O:{0}", countO); + Console.WriteLine("U:{0}", countU); + } + } +} diff --git a/15_5/15_5.csproj b/15_5/15_5.csproj new file mode 100644 index 0000000..c5a7931 --- /dev/null +++ b/15_5/15_5.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _15_5 + enable + enable + + + diff --git a/15_5/15_5.sln b/15_5/15_5.sln new file mode 100644 index 0000000..54dcc6d --- /dev/null +++ b/15_5/15_5.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "15_5", "15_5.csproj", "{79BC6493-706C-4DCF-A78E-30B0D2CB1FA8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {79BC6493-706C-4DCF-A78E-30B0D2CB1FA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79BC6493-706C-4DCF-A78E-30B0D2CB1FA8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79BC6493-706C-4DCF-A78E-30B0D2CB1FA8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79BC6493-706C-4DCF-A78E-30B0D2CB1FA8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {908C2BE7-032B-4A3E-BCBD-721A5B8AF689} + EndGlobalSection +EndGlobal diff --git a/15_5/Program.cs b/15_5/Program.cs new file mode 100644 index 0000000..dfa145e --- /dev/null +++ b/15_5/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Text; + +namespace _15_5 +{ + internal class Program + { + static void Main(string[] args) + { + StringBuilder sb = new StringBuilder("ABC", 50); + sb.Append(new char[] { 'D', 'F', 'E' }); + sb.AppendFormat("GHI{0}{1}", 'J', 'k'); + Console.WriteLine("{0} chars,内容为{1}", sb.Length, sb.ToString()); + sb.Insert(0, "Alphabet---"); + sb.Replace('k', 'K'); + Console.WriteLine("{0} chars,内容为{1}", sb.Length, sb.ToString()); + } + } +} diff --git a/15_7/15_7.csproj b/15_7/15_7.csproj new file mode 100644 index 0000000..40810c7 --- /dev/null +++ b/15_7/15_7.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _15_7 + enable + enable + + + diff --git a/15_7/15_7.sln b/15_7/15_7.sln new file mode 100644 index 0000000..37d663f --- /dev/null +++ b/15_7/15_7.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "15_7", "15_7.csproj", "{79C1A3AF-2C09-4966-8EC3-9156C7A58750}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {79C1A3AF-2C09-4966-8EC3-9156C7A58750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79C1A3AF-2C09-4966-8EC3-9156C7A58750}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79C1A3AF-2C09-4966-8EC3-9156C7A58750}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79C1A3AF-2C09-4966-8EC3-9156C7A58750}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {322B6BB6-0C56-4401-8745-CB8F1D6304A0} + EndGlobalSection +EndGlobal diff --git a/15_7/Program.cs b/15_7/Program.cs new file mode 100644 index 0000000..e22a1e6 --- /dev/null +++ b/15_7/Program.cs @@ -0,0 +1,23 @@ +using System.Text.RegularExpressions; + +namespace _15_7 +{ + internal class Program + { + static void Main(string[] args) + { + MatchCollection mc; + string[] result = new string[20]; int[] matchposition = new int[20]; + Regex r = new Regex("abc"); + mc = r.Matches("123abc4abcd"); + Console.WriteLine("源字符串123abc4abcd"); + Console.WriteLine("匹配字符串abc"); + for (int i = 0; i < mc.Count; i++) + { + result[i] = mc[i].Value; + matchposition[i] = mc[i].Index; + Console.WriteLine("索引位置{0};结果{1};", mc[i].Index, mc[i].Value); + } + } + } +} diff --git a/15_8/15_8.csproj b/15_8/15_8.csproj new file mode 100644 index 0000000..b410535 --- /dev/null +++ b/15_8/15_8.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _15_8 + enable + enable + + + diff --git a/15_8/15_8.sln b/15_8/15_8.sln new file mode 100644 index 0000000..e2f79ea --- /dev/null +++ b/15_8/15_8.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "15_8", "15_8.csproj", "{F3D96B0F-364E-4EAB-9C50-8EABCE6F748E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F3D96B0F-364E-4EAB-9C50-8EABCE6F748E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F3D96B0F-364E-4EAB-9C50-8EABCE6F748E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F3D96B0F-364E-4EAB-9C50-8EABCE6F748E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F3D96B0F-364E-4EAB-9C50-8EABCE6F748E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {22C79536-29FB-4BFC-BC82-AC3EFA5DF606} + EndGlobalSection +EndGlobal diff --git a/15_8/Program.cs b/15_8/Program.cs new file mode 100644 index 0000000..7f543ff --- /dev/null +++ b/15_8/Program.cs @@ -0,0 +1,16 @@ +using System; +using System.Text.RegularExpressions; + +namespace _15_8 +{ + internal class Program + { + static void Main(string[] args) + { + string strIn = @"~@ How are you doing? Fine,thanks!"; + string result = Regex.Replace(strIn, @"[^\w\. ?,]", ""); + Console.WriteLine(strIn); + Console.WriteLine(result); + } + } +} diff --git a/15_9/15_9.csproj b/15_9/15_9.csproj new file mode 100644 index 0000000..340a56a --- /dev/null +++ b/15_9/15_9.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _15_9 + enable + enable + + + diff --git a/15_9/15_9.sln b/15_9/15_9.sln new file mode 100644 index 0000000..b3854f4 --- /dev/null +++ b/15_9/15_9.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "15_9", "15_9.csproj", "{42964642-3419-4B4C-82EE-6648B8E1AF09}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {42964642-3419-4B4C-82EE-6648B8E1AF09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42964642-3419-4B4C-82EE-6648B8E1AF09}.Debug|Any CPU.Build.0 = Debug|Any CPU + {42964642-3419-4B4C-82EE-6648B8E1AF09}.Release|Any CPU.ActiveCfg = Release|Any CPU + {42964642-3419-4B4C-82EE-6648B8E1AF09}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0E8A3FC7-2195-445C-89F7-8C03A042ADC5} + EndGlobalSection +EndGlobal diff --git a/15_9/Program.cs b/15_9/Program.cs new file mode 100644 index 0000000..3d282d2 --- /dev/null +++ b/15_9/Program.cs @@ -0,0 +1,10 @@ +namespace _15_9 +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello, World!"); + } + } +} diff --git a/16/16.csproj b/16/16.csproj new file mode 100644 index 0000000..4e4b3d9 --- /dev/null +++ b/16/16.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _16 + enable + enable + + + diff --git a/16/16.sln b/16/16.sln new file mode 100644 index 0000000..f4ab1e4 --- /dev/null +++ b/16/16.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "16", "16.csproj", "{A5B25E25-EF1D-47F6-AB55-E0AC5C40E712}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A5B25E25-EF1D-47F6-AB55-E0AC5C40E712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5B25E25-EF1D-47F6-AB55-E0AC5C40E712}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5B25E25-EF1D-47F6-AB55-E0AC5C40E712}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5B25E25-EF1D-47F6-AB55-E0AC5C40E712}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F7A0EDA2-542E-4CE2-91F6-575C0D8277BC} + EndGlobalSection +EndGlobal diff --git a/16/Program.cs b/16/Program.cs new file mode 100644 index 0000000..56b0d8a --- /dev/null +++ b/16/Program.cs @@ -0,0 +1,22 @@ +namespace _16 +{ + internal class Program + { + private const string FILE_NAME = @"c:\temp\TestFile.txt"; + static void Main(string[] args) + { + using (StreamReader sr = new StreamReader(FILE_NAME)) + { + try + { + String line; + while ((line = sr.ReadLine()) != null) + { + Console.WriteLine(line); + } + } + catch (Exception e) { Console.WriteLine(e.Message); } + } + } + } +} diff --git a/16_2/16_2.csproj b/16_2/16_2.csproj new file mode 100644 index 0000000..b17655b --- /dev/null +++ b/16_2/16_2.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _16_2 + enable + enable + + + diff --git a/16_2/16_2.sln b/16_2/16_2.sln new file mode 100644 index 0000000..ed429a7 --- /dev/null +++ b/16_2/16_2.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "16_2", "16_2.csproj", "{894B436F-A57A-4945-9B44-C9F2999B099D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {894B436F-A57A-4945-9B44-C9F2999B099D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {894B436F-A57A-4945-9B44-C9F2999B099D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {894B436F-A57A-4945-9B44-C9F2999B099D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {894B436F-A57A-4945-9B44-C9F2999B099D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D6F600F8-25B4-4E93-AF52-22E987FC78C2} + EndGlobalSection +EndGlobal diff --git a/16_2/Program.cs b/16_2/Program.cs new file mode 100644 index 0000000..abeaf99 --- /dev/null +++ b/16_2/Program.cs @@ -0,0 +1,33 @@ +using System; +using System.IO; + +namespace _16_2 +{ + class CopyDir + { + static public void CopyDirectory(string srcDir, string dstDir) + { + DirectoryInfo src = new DirectoryInfo(srcDir); + DirectoryInfo dst = new DirectoryInfo(dstDir); + if (!src.Exists) return; + if (!dst.Exists) dst.Create(); + FileInfo[] sfs = src.GetFiles(); + for (int i = 0; i < sfs.Length; i++) File.Copy(sfs[i].FullName, sfs[i].FullName + "\\" + sfs[i].Name, true); + DirectoryInfo[] srcDirs = src.GetDirectories(); + for (int j = 0; j < srcDirs.Length; j++) + CopyDirectory(srcDirs[j].FullName, dst.FullName + "\\" + srcDirs[j].Name); + } + static void Main(string[] args) + { + try + { + string src = args[0]; + string dst = args[1]; + CopyDirectory(src, dst); + Console.WriteLine("\n 源目录{0}的内容已复制到目标目录{1}中", src, dst); + } + catch (Exception e) { Console.WriteLine("\n 操作失败 {0}", e.ToString()); } + finally { } + } + } +} \ No newline at end of file diff --git a/16_3/16_3.csproj b/16_3/16_3.csproj new file mode 100644 index 0000000..b5007f7 --- /dev/null +++ b/16_3/16_3.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _16_3 + enable + enable + + + diff --git a/16_3/16_3.sln b/16_3/16_3.sln new file mode 100644 index 0000000..659fe33 --- /dev/null +++ b/16_3/16_3.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "16_3", "16_3.csproj", "{516064BC-53EE-4754-B189-5AF7DE4BA648}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {516064BC-53EE-4754-B189-5AF7DE4BA648}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {516064BC-53EE-4754-B189-5AF7DE4BA648}.Debug|Any CPU.Build.0 = Debug|Any CPU + {516064BC-53EE-4754-B189-5AF7DE4BA648}.Release|Any CPU.ActiveCfg = Release|Any CPU + {516064BC-53EE-4754-B189-5AF7DE4BA648}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {592FA477-A757-4C0E-83CA-53B7B59DDBEF} + EndGlobalSection +EndGlobal diff --git a/16_3/Program.cs b/16_3/Program.cs new file mode 100644 index 0000000..72397ab --- /dev/null +++ b/16_3/Program.cs @@ -0,0 +1,26 @@ +using System; +using System.IO; + +namespace _16_3 +{ + class Program + { + private const string FILE_NAME = @"c:\temp\TestFile.txt"; + static void Main(string[] args) + { + using (StreamWriter sw = new StreamWriter(FILE_NAME)) + { + sw.Write("文本文件"); + sw.Write("的写入/读取"); + sw.WriteLine("-----------------------"); + sw.WriteLine("写入整数{0},或浮点数{1}", 1, 4.2); + bool b = false; char grade ='A'; string s = "Multiple Data Type!"; + sw.WriteLine("写入布尔值、字符、字符串、日期:"); + sw.WriteLine(b); + sw.WriteLine(grade); + sw.WriteLine(s); + sw.Write("当前日期:");sw.WriteLine(DateTime.Now); + } + } + } +} diff --git a/16_7/16_7.csproj b/16_7/16_7.csproj new file mode 100644 index 0000000..2ce8269 --- /dev/null +++ b/16_7/16_7.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _16_7 + enable + enable + + + diff --git a/16_7/16_7.sln b/16_7/16_7.sln new file mode 100644 index 0000000..13a5d44 --- /dev/null +++ b/16_7/16_7.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "16_7", "16_7.csproj", "{33890FA2-C6D8-4655-9C73-C57015E7EDA2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {33890FA2-C6D8-4655-9C73-C57015E7EDA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {33890FA2-C6D8-4655-9C73-C57015E7EDA2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {33890FA2-C6D8-4655-9C73-C57015E7EDA2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {33890FA2-C6D8-4655-9C73-C57015E7EDA2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6B7FEDF5-3E35-4C46-886A-78630949426A} + EndGlobalSection +EndGlobal diff --git a/16_7/Program.cs b/16_7/Program.cs new file mode 100644 index 0000000..bfaa4b4 --- /dev/null +++ b/16_7/Program.cs @@ -0,0 +1,10 @@ +namespace _16_7 +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello, World!"); + } + } +} diff --git a/ConsoleApp7/ConsoleApp7.csproj b/ConsoleApp7/ConsoleApp7.csproj new file mode 100644 index 0000000..2150e37 --- /dev/null +++ b/ConsoleApp7/ConsoleApp7.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/ConsoleApp7/ConsoleApp7.sln b/ConsoleApp7/ConsoleApp7.sln new file mode 100644 index 0000000..720e84e --- /dev/null +++ b/ConsoleApp7/ConsoleApp7.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp7", "ConsoleApp7.csproj", "{D142C263-3F9B-4B2C-96D8-91555668D07F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D142C263-3F9B-4B2C-96D8-91555668D07F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D142C263-3F9B-4B2C-96D8-91555668D07F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D142C263-3F9B-4B2C-96D8-91555668D07F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D142C263-3F9B-4B2C-96D8-91555668D07F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A6F2247D-28F8-40E7-A68F-9A39C987FF1D} + EndGlobalSection +EndGlobal diff --git a/ConsoleApp7/Program.cs b/ConsoleApp7/Program.cs new file mode 100644 index 0000000..aaecafd --- /dev/null +++ b/ConsoleApp7/Program.cs @@ -0,0 +1,26 @@ + +namespace ConsoleApp7 +{ + internal class Program + { + static void Main() + { + DriveInfo[] allDrives = DriveInfo.GetDrives(); + foreach (DriveInfo d in allDrives) + { + Console.WriteLine(d.Name); + Console.WriteLine(d.DriveType); + if (d.IsReady == true) + { + Console.WriteLine("卷标{0}", d.VolumeLabel); + Console.WriteLine("文件系统{0}", d.DriveFormat); + Console.WriteLine("可用空间{0,15}bytes", d.AvailableFreeSpace); + Console.WriteLine("总可用空间{0,15}bytes", d.TotalFreeSpace); + Console.WriteLine("磁盘总大小{0,15}bytes", d.TotalSize); + } + + } + + } + } +} diff --git a/HelloWorld/App.config b/HelloWorld/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/HelloWorld/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/HelloWorld/Form1.Designer.cs b/HelloWorld/Form1.Designer.cs new file mode 100644 index 0000000..90263cb --- /dev/null +++ b/HelloWorld/Form1.Designer.cs @@ -0,0 +1,64 @@ +namespace HelloWorld +{ + partial class Hello_World + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Font = new System.Drawing.Font("宋体", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(236, 156); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(591, 426); + this.button1.TabIndex = 0; + this.button1.Text = "say"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // Hello_World + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1054, 769); + this.Controls.Add(this.button1); + this.Cursor = System.Windows.Forms.Cursors.Cross; + this.Name = "Hello_World"; + this.Text = "Hello World"; + this.Load += new System.EventHandler(this.Form1_Load); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button button1; + } +} + diff --git a/HelloWorld/Form1.cs b/HelloWorld/Form1.cs new file mode 100644 index 0000000..c630c8f --- /dev/null +++ b/HelloWorld/Form1.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace HelloWorld +{ + public partial class Hello_World : Form + { + public Hello_World() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + MessageBox.Show("Hello World"); + } + + private void Form1_Load(object sender, EventArgs e) + { + + } + } +} diff --git a/HelloWorld/Form1.resx b/HelloWorld/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/HelloWorld/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/HelloWorld/HelloWorld.csproj b/HelloWorld/HelloWorld.csproj new file mode 100644 index 0000000..831eb90 --- /dev/null +++ b/HelloWorld/HelloWorld.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {E37BC2C4-B352-4A78-BD8A-3CDDF322D223} + WinExe + HelloWorld + HelloWorld + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/HelloWorld/HelloWorld.sln b/HelloWorld/HelloWorld.sln new file mode 100644 index 0000000..efb58d2 --- /dev/null +++ b/HelloWorld/HelloWorld.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36705.20 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "HelloWorld.csproj", "{E37BC2C4-B352-4A78-BD8A-3CDDF322D223}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E37BC2C4-B352-4A78-BD8A-3CDDF322D223}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E37BC2C4-B352-4A78-BD8A-3CDDF322D223}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E37BC2C4-B352-4A78-BD8A-3CDDF322D223}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E37BC2C4-B352-4A78-BD8A-3CDDF322D223}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4D8B2E62-4DC9-4BD4-956F-2846C6B73BEA} + EndGlobalSection +EndGlobal diff --git a/HelloWorld/Program.cs b/HelloWorld/Program.cs new file mode 100644 index 0000000..dfc2cd2 --- /dev/null +++ b/HelloWorld/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace HelloWorld +{ + internal static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Hello_World()); + } + } +} diff --git a/HelloWorld/Properties/AssemblyInfo.cs b/HelloWorld/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6c908db --- /dev/null +++ b/HelloWorld/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("HelloWorld")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HelloWorld")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("e37bc2c4-b352-4a78-bd8a-3cddf322d223")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/HelloWorld/Properties/Resources.Designer.cs b/HelloWorld/Properties/Resources.Designer.cs new file mode 100644 index 0000000..6572604 --- /dev/null +++ b/HelloWorld/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace HelloWorld.Properties +{ + + + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HelloWorld.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/HelloWorld/Properties/Resources.resx b/HelloWorld/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/HelloWorld/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/HelloWorld/Properties/Settings.Designer.cs b/HelloWorld/Properties/Settings.Designer.cs new file mode 100644 index 0000000..3193610 --- /dev/null +++ b/HelloWorld/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace HelloWorld.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/HelloWorld/Properties/Settings.settings b/HelloWorld/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/HelloWorld/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/WindowsFormsApp1/App.config b/WindowsFormsApp1/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/WindowsFormsApp1/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/WindowsFormsApp1/Form1.Designer.cs b/WindowsFormsApp1/Form1.Designer.cs new file mode 100644 index 0000000..9dd45bb --- /dev/null +++ b/WindowsFormsApp1/Form1.Designer.cs @@ -0,0 +1,103 @@ +namespace WindowsFormsApp1 +{ + partial class Form1 + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(55, 52); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(44, 18); + this.label1.TabIndex = 0; + this.label1.Text = "复制"; + // + // richTextBox1 + // + this.richTextBox1.Location = new System.Drawing.Point(78, 109); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.ReadOnly = true; + this.richTextBox1.Size = new System.Drawing.Size(295, 217); + this.richTextBox1.TabIndex = 1; + this.richTextBox1.Text = ""; + this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(366, 364); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(94, 44); + this.button1.TabIndex = 2; + this.button1.Text = "复制文字"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // textBox1 + // + this.textBox1.CausesValidation = false; + this.textBox1.Location = new System.Drawing.Point(439, 109); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox1.Size = new System.Drawing.Size(302, 217); + this.textBox1.TabIndex = 3; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.button1); + this.Controls.Add(this.richTextBox1); + this.Controls.Add(this.label1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.TextBox textBox1; + } +} + diff --git a/WindowsFormsApp1/Form1.cs b/WindowsFormsApp1/Form1.cs new file mode 100644 index 0000000..344fa58 --- /dev/null +++ b/WindowsFormsApp1/Form1.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace WindowsFormsApp1 +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + + private void richTextBox1_TextChanged(object sender, EventArgs e) + { + + } + + private void Form1_Load(object sender, EventArgs e) + { + richTextBox1.Text = @"TextBox控件用于输入文本信息" + + @"此控件具有windows文本框控件所没有的" + + @"附加功能,包括多行编辑和密码字符屏蔽"; + textBox1.Text = ""; + } + + private void button1_Click(object sender, EventArgs e) + { + textBox1.Text += richTextBox1.SelectedText; + richTextBox1.SelectionFont = new Font("Kaiti", 24, FontStyle.Bold); + richTextBox1.SelectionColor = System.Drawing.Color.Red; + } + } +} diff --git a/WindowsFormsApp1/Form1.resx b/WindowsFormsApp1/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp1/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WindowsFormsApp1/Program.cs b/WindowsFormsApp1/Program.cs new file mode 100644 index 0000000..389dad4 --- /dev/null +++ b/WindowsFormsApp1/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace WindowsFormsApp1 +{ + internal static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/WindowsFormsApp1/Properties/AssemblyInfo.cs b/WindowsFormsApp1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e59e659 --- /dev/null +++ b/WindowsFormsApp1/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("WindowsFormsApp1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WindowsFormsApp1")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("96efcf33-f88b-4af9-a162-8b3e87c946ec")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/WindowsFormsApp1/Properties/Resources.Designer.cs b/WindowsFormsApp1/Properties/Resources.Designer.cs new file mode 100644 index 0000000..8b479b7 --- /dev/null +++ b/WindowsFormsApp1/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace WindowsFormsApp1.Properties +{ + + + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsFormsApp1.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/WindowsFormsApp1/Properties/Resources.resx b/WindowsFormsApp1/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/WindowsFormsApp1/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WindowsFormsApp1/Properties/Settings.Designer.cs b/WindowsFormsApp1/Properties/Settings.Designer.cs new file mode 100644 index 0000000..438df21 --- /dev/null +++ b/WindowsFormsApp1/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WindowsFormsApp1.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/WindowsFormsApp1/Properties/Settings.settings b/WindowsFormsApp1/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/WindowsFormsApp1/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/WindowsFormsApp1/WindowsFormsApp1.csproj b/WindowsFormsApp1/WindowsFormsApp1.csproj new file mode 100644 index 0000000..7a6d8e7 --- /dev/null +++ b/WindowsFormsApp1/WindowsFormsApp1.csproj @@ -0,0 +1,124 @@ + + + + + Debug + AnyCPU + {96EFCF33-F88B-4AF9-A162-8B3E87C946EC} + WinExe + WindowsFormsApp1 + WindowsFormsApp1 + v4.7.2 + 512 + true + true + false + C:\Users\BI\Desktop\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 1 + 1.0.0.%2a + false + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + 5FE4E351DDEE03F11108E06DB0BCCC3691E5FDCD + + + WindowsFormsApp1_TemporaryKey.pfx + + + true + + + true + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + False + Microsoft .NET Framework 4.7.2 %28x86 和 x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + \ No newline at end of file diff --git a/WindowsFormsApp1/WindowsFormsApp1.sln b/WindowsFormsApp1/WindowsFormsApp1.sln new file mode 100644 index 0000000..58a4898 --- /dev/null +++ b/WindowsFormsApp1/WindowsFormsApp1.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36705.20 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsApp1", "WindowsFormsApp1.csproj", "{96EFCF33-F88B-4AF9-A162-8B3E87C946EC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {96EFCF33-F88B-4AF9-A162-8B3E87C946EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {96EFCF33-F88B-4AF9-A162-8B3E87C946EC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {96EFCF33-F88B-4AF9-A162-8B3E87C946EC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {96EFCF33-F88B-4AF9-A162-8B3E87C946EC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BB850310-348D-44FF-AB13-148BBCDD72FA} + EndGlobalSection +EndGlobal diff --git a/WindowsFormsApp1/WindowsFormsApp1_TemporaryKey.pfx b/WindowsFormsApp1/WindowsFormsApp1_TemporaryKey.pfx new file mode 100644 index 0000000..7e14d20 Binary files /dev/null and b/WindowsFormsApp1/WindowsFormsApp1_TemporaryKey.pfx differ diff --git a/WindowsFormsApp2/App.config b/WindowsFormsApp2/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/WindowsFormsApp2/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/WindowsFormsApp2/Form1.Designer.cs b/WindowsFormsApp2/Form1.Designer.cs new file mode 100644 index 0000000..5a5412e --- /dev/null +++ b/WindowsFormsApp2/Form1.Designer.cs @@ -0,0 +1,242 @@ +namespace WindowsFormsApp2 +{ + partial class Diaocha + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.Name = new System.Windows.Forms.TextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.radioButton2 = new System.Windows.Forms.RadioButton(); + this.radioButton1 = new System.Windows.Forms.RadioButton(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.checkBox4 = new System.Windows.Forms.CheckBox(); + this.checkBox3 = new System.Windows.Forms.CheckBox(); + this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.button1 = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.Message = new System.Windows.Forms.Label(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(163, 39); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(180, 28); + this.label1.TabIndex = 0; + this.label1.Text = "个人信息调查"; + // + // Name + // + this.Name.Location = new System.Drawing.Point(150, 95); + this.Name.Name = "Name"; + this.Name.Size = new System.Drawing.Size(238, 28); + this.Name.TabIndex = 1; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.radioButton2); + this.groupBox1.Controls.Add(this.radioButton1); + this.groupBox1.Location = new System.Drawing.Point(150, 163); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(238, 50); + this.groupBox1.TabIndex = 2; + this.groupBox1.TabStop = false; + // + // radioButton2 + // + this.radioButton2.AutoSize = true; + this.radioButton2.Location = new System.Drawing.Point(125, 14); + this.radioButton2.Name = "radioButton2"; + this.radioButton2.Size = new System.Drawing.Size(51, 22); + this.radioButton2.TabIndex = 1; + this.radioButton2.TabStop = true; + this.radioButton2.Text = "女"; + this.radioButton2.UseVisualStyleBackColor = true; + // + // radioButton1 + // + this.radioButton1.AutoSize = true; + this.radioButton1.Location = new System.Drawing.Point(18, 14); + this.radioButton1.Name = "radioButton1"; + this.radioButton1.Size = new System.Drawing.Size(51, 22); + this.radioButton1.TabIndex = 0; + this.radioButton1.TabStop = true; + this.radioButton1.Text = "男"; + this.radioButton1.UseVisualStyleBackColor = true; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.checkBox4); + this.groupBox2.Controls.Add(this.checkBox3); + this.groupBox2.Controls.Add(this.checkBox2); + this.groupBox2.Controls.Add(this.checkBox1); + this.groupBox2.Location = new System.Drawing.Point(150, 259); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(238, 100); + this.groupBox2.TabIndex = 3; + this.groupBox2.TabStop = false; + // + // checkBox4 + // + this.checkBox4.AutoSize = true; + this.checkBox4.Location = new System.Drawing.Point(125, 65); + this.checkBox4.Name = "checkBox4"; + this.checkBox4.Size = new System.Drawing.Size(70, 22); + this.checkBox4.TabIndex = 3; + this.checkBox4.Text = "运动"; + this.checkBox4.UseVisualStyleBackColor = true; + // + // checkBox3 + // + this.checkBox3.AutoSize = true; + this.checkBox3.Location = new System.Drawing.Point(18, 66); + this.checkBox3.Name = "checkBox3"; + this.checkBox3.Size = new System.Drawing.Size(70, 22); + this.checkBox3.TabIndex = 2; + this.checkBox3.Text = "阅读"; + this.checkBox3.UseVisualStyleBackColor = true; + // + // checkBox2 + // + this.checkBox2.AutoSize = true; + this.checkBox2.Location = new System.Drawing.Point(125, 27); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(70, 22); + this.checkBox2.TabIndex = 1; + this.checkBox2.Text = "旅游"; + this.checkBox2.UseVisualStyleBackColor = true; + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(18, 28); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(70, 22); + this.checkBox1.TabIndex = 0; + this.checkBox1.Text = "音乐"; + this.checkBox1.UseVisualStyleBackColor = true; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(198, 388); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 29); + this.button1.TabIndex = 4; + this.button1.Text = "提交"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(61, 98); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(44, 18); + this.label2.TabIndex = 5; + this.label2.Text = "姓名"; + this.label2.Click += new System.EventHandler(this.label2_Click); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(64, 176); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(44, 18); + this.label3.TabIndex = 6; + this.label3.Text = "性别"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(64, 268); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(44, 18); + this.label4.TabIndex = 7; + this.label4.Text = "爱好"; + // + // Message + // + this.Message.AutoSize = true; + this.Message.Location = new System.Drawing.Point(96, 428); + this.Message.Name = "Message"; + this.Message.Size = new System.Drawing.Size(62, 18); + this.Message.TabIndex = 8; + this.Message.Text = "label5"; + // + // Diaocha + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(460, 523); + this.Controls.Add(this.Message); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.button1); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.Name); + this.Controls.Add(this.label1); + this.Name = "Diaocha"; + this.Text = "调查"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox Name; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.RadioButton radioButton2; + private System.Windows.Forms.RadioButton radioButton1; + private System.Windows.Forms.CheckBox checkBox4; + private System.Windows.Forms.CheckBox checkBox3; + private System.Windows.Forms.CheckBox checkBox2; + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label Message; + } +} + diff --git a/WindowsFormsApp2/Form1.cs b/WindowsFormsApp2/Form1.cs new file mode 100644 index 0000000..988ba24 --- /dev/null +++ b/WindowsFormsApp2/Form1.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace WindowsFormsApp2 +{ + public partial class Diaocha : Form + { + public Diaocha() + { + InitializeComponent(); + } + + private void label2_Click(object sender, EventArgs e) + { + + } + + private void button1_Click(object sender, EventArgs e) + { + Message.Text = Name + "您好!"; + if (radioButton1.Checked) Message.Text += "\n 您的性别是:" + radioButton1.Text; + else if (radioButton2.Checked) Message.Text += "\n 您的性别是:" + radioButton2.Text; + Message.Text += "\n 您的爱好是:"; + if (checkBox1.Checked) Message.Text += checkBox1.Text + ""; + if (checkBox2.Checked) Message.Text += checkBox2.Text + ""; + if (checkBox3.Checked) Message.Text += checkBox3.Text + ""; + if (checkBox4.Checked) Message.Text += checkBox4.Text + ""; + if (!checkBox1.Checked && !checkBox2.Checked && !checkBox3.Checked && !checkBox4.Checked) + Message.Text += "您居然没有兴趣爱好!"; + } + } +} diff --git a/WindowsFormsApp2/Form1.resx b/WindowsFormsApp2/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp2/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WindowsFormsApp2/Program.cs b/WindowsFormsApp2/Program.cs new file mode 100644 index 0000000..ba7cc40 --- /dev/null +++ b/WindowsFormsApp2/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace WindowsFormsApp2 +{ + internal static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Diaocha()); + } + } +} diff --git a/WindowsFormsApp2/Properties/AssemblyInfo.cs b/WindowsFormsApp2/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f7183b3 --- /dev/null +++ b/WindowsFormsApp2/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("WindowsFormsApp2")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WindowsFormsApp2")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("da844edf-3c52-4daf-9cc5-4fbb4bc3d243")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/WindowsFormsApp2/Properties/Resources.Designer.cs b/WindowsFormsApp2/Properties/Resources.Designer.cs new file mode 100644 index 0000000..cff3934 --- /dev/null +++ b/WindowsFormsApp2/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace WindowsFormsApp2.Properties +{ + + + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsFormsApp2.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/WindowsFormsApp2/Properties/Resources.resx b/WindowsFormsApp2/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/WindowsFormsApp2/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WindowsFormsApp2/Properties/Settings.Designer.cs b/WindowsFormsApp2/Properties/Settings.Designer.cs new file mode 100644 index 0000000..559507f --- /dev/null +++ b/WindowsFormsApp2/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WindowsFormsApp2.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/WindowsFormsApp2/Properties/Settings.settings b/WindowsFormsApp2/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/WindowsFormsApp2/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/WindowsFormsApp2/WindowsFormsApp2.csproj b/WindowsFormsApp2/WindowsFormsApp2.csproj new file mode 100644 index 0000000..3d30b75 --- /dev/null +++ b/WindowsFormsApp2/WindowsFormsApp2.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {DA844EDF-3C52-4DAF-9CC5-4FBB4BC3D243} + WinExe + WindowsFormsApp2 + WindowsFormsApp2 + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/WindowsFormsApp2/WindowsFormsApp2.sln b/WindowsFormsApp2/WindowsFormsApp2.sln new file mode 100644 index 0000000..4632e1f --- /dev/null +++ b/WindowsFormsApp2/WindowsFormsApp2.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36705.20 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsApp2", "WindowsFormsApp2.csproj", "{DA844EDF-3C52-4DAF-9CC5-4FBB4BC3D243}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DA844EDF-3C52-4DAF-9CC5-4FBB4BC3D243}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DA844EDF-3C52-4DAF-9CC5-4FBB4BC3D243}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA844EDF-3C52-4DAF-9CC5-4FBB4BC3D243}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DA844EDF-3C52-4DAF-9CC5-4FBB4BC3D243}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D29C43C0-ABD6-4F3C-B8A1-4FB512380B60} + EndGlobalSection +EndGlobal diff --git a/cs4/CPP5/CPP5.cpp b/cs4/CPP5/CPP5.cpp index 39f946e..b4322f2 100644 --- a/cs4/CPP5/CPP5.cpp +++ b/cs4/CPP5/CPP5.cpp @@ -1,20 +1,89 @@ -// CPP5.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 -// +#include +#include +#include -#include +typedef struct Node +{ + int data; + Node* next; +} Node; + +// 链式基数排序 +Node* radixSort(Node* head) +{ + if (head == NULL) return NULL; + int max = head->data; + Node* current = head; + while (current != NULL) + { + if (current->data > max) max = current->data; + current = current->next; + } + // 基数排序 + for (int exp = 1; max / exp > 0; exp *= 10) + { + Node* buckets[10] = { NULL }; + Node* tails[10] = { NULL }; + current = head; + while (current != NULL) + { + Node* next = current->next; // 保存下一个节点 + current->next = NULL; // 断开,防止形成环或错连 + + int digit = (current->data / exp) % 10; + if (buckets[digit] == NULL) + { + buckets[digit] = current; + tails[digit] = current; + } + else + { + tails[digit]->next = current; + tails[digit] = current; + } + current = next; + } + Node* newHead = NULL; + Node* newTail = NULL; + for (int i = 0; i < 10; i++) + { + if (buckets[i] != NULL) + { + if (newHead == NULL) + { + newHead = buckets[i]; + newTail = tails[i]; + } + else + { + newTail->next = buckets[i]; + newTail = tails[i]; + } + } + } + if (newTail != NULL) + newTail->next = NULL; + head = newHead; + } + return head; +} int main() { - std::cout << "Hello World!\n"; -} - -// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单 -// 调试程序: F5 或调试 >“开始调试”菜单 - -// 入门使用技巧: -// 1. 使用解决方案资源管理器窗口添加/管理文件 -// 2. 使用团队资源管理器窗口连接到源代码管理 -// 3. 使用输出窗口查看生成输出和其他消息 -// 4. 使用错误列表窗口查看错误 -// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目 -// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件 + srand((unsigned int)time(NULL)); + Node* head = NULL; + for (int i = 0; i < 100000; i++) + { + Node* newNode = (Node*)malloc(sizeof(Node)); + newNode->data = rand() % 100; + newNode->next = head; + head = newNode; + } + printf("链表已创建!\n"); + double clock1 = clock(); + head = radixSort(head); + double clock2 = clock(); + printf("排序完成:\n"); + printf("排序时间: %f 秒\n", (double)(clock2 - clock1) / CLOCKS_PER_SEC); + return 0; +} \ No newline at end of file diff --git a/cs4/CPP5/作业5.cpp b/cs4/CPP5/作业5.cpp new file mode 100644 index 0000000..b4322f2 --- /dev/null +++ b/cs4/CPP5/作业5.cpp @@ -0,0 +1,89 @@ +#include +#include +#include + +typedef struct Node +{ + int data; + Node* next; +} Node; + +// 链式基数排序 +Node* radixSort(Node* head) +{ + if (head == NULL) return NULL; + int max = head->data; + Node* current = head; + while (current != NULL) + { + if (current->data > max) max = current->data; + current = current->next; + } + // 基数排序 + for (int exp = 1; max / exp > 0; exp *= 10) + { + Node* buckets[10] = { NULL }; + Node* tails[10] = { NULL }; + current = head; + while (current != NULL) + { + Node* next = current->next; // 保存下一个节点 + current->next = NULL; // 断开,防止形成环或错连 + + int digit = (current->data / exp) % 10; + if (buckets[digit] == NULL) + { + buckets[digit] = current; + tails[digit] = current; + } + else + { + tails[digit]->next = current; + tails[digit] = current; + } + current = next; + } + Node* newHead = NULL; + Node* newTail = NULL; + for (int i = 0; i < 10; i++) + { + if (buckets[i] != NULL) + { + if (newHead == NULL) + { + newHead = buckets[i]; + newTail = tails[i]; + } + else + { + newTail->next = buckets[i]; + newTail = tails[i]; + } + } + } + if (newTail != NULL) + newTail->next = NULL; + head = newHead; + } + return head; +} + +int main() +{ + srand((unsigned int)time(NULL)); + Node* head = NULL; + for (int i = 0; i < 100000; i++) + { + Node* newNode = (Node*)malloc(sizeof(Node)); + newNode->data = rand() % 100; + newNode->next = head; + head = newNode; + } + printf("链表已创建!\n"); + double clock1 = clock(); + head = radixSort(head); + double clock2 = clock(); + printf("排序完成:\n"); + printf("排序时间: %f 秒\n", (double)(clock2 - clock1) / CLOCKS_PER_SEC); + return 0; +} \ No newline at end of file diff --git a/cs5/5_4/5_4.csproj b/cs5/5_4/5_4.csproj new file mode 100644 index 0000000..bdd5a6e --- /dev/null +++ b/cs5/5_4/5_4.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _5_4 + enable + enable + + + diff --git a/cs5/5_4/5_4.sln b/cs5/5_4/5_4.sln new file mode 100644 index 0000000..14b3348 --- /dev/null +++ b/cs5/5_4/5_4.sln @@ -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_4", "5_4.csproj", "{43F29EB3-99B5-4064-911E-3B3570272923}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {43F29EB3-99B5-4064-911E-3B3570272923}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {43F29EB3-99B5-4064-911E-3B3570272923}.Debug|Any CPU.Build.0 = Debug|Any CPU + {43F29EB3-99B5-4064-911E-3B3570272923}.Release|Any CPU.ActiveCfg = Release|Any CPU + {43F29EB3-99B5-4064-911E-3B3570272923}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {20D2A0A1-A7D4-4CAC-BC03-AACF2D5F63B0} + EndGlobalSection +EndGlobal diff --git a/cs5/5_4/Program.cs b/cs5/5_4/Program.cs new file mode 100644 index 0000000..4fcfa88 --- /dev/null +++ b/cs5/5_4/Program.cs @@ -0,0 +1,60 @@ +namespace _5_4 +{ + public abstract class Shape + { + protected string name; + public Shape(string name) + { + this.name = name; + } + public abstract void Show(); + public abstract double Area(); + } + public class Rectangle : Shape + { + protected double width; + protected double height; + public Rectangle(string name, double width, double height) : base(name) + { + this.width = width; + this.height = height; + } + public override void Show() + { + Console.WriteLine("Rectangle: {0} , area :{1}", name, width * height); + } + public override double Area() + { + return width * height; + } + } + public class Circle : Shape + { + protected double radius; + public Circle(string name, double radius) : base(name) + { + this.radius = radius; + } + public override void Show() + { + Console.WriteLine("Circle: {0} , area :{1}", name, Math.PI * radius * radius); + } + public override double Area() + { + return Math.PI * radius * radius; + } + } + public class Program + { + static void Main(string[] args) + { + Shape[] s = { new Rectangle("小矩形",1.0,2.0), + new Circle("大源",5.0), + }; + foreach (Shape shape in s) + { + shape.Show(); + } + } + } +} diff --git a/cs5/5_5/5_5.csproj b/cs5/5_5/5_5.csproj new file mode 100644 index 0000000..27e85b5 --- /dev/null +++ b/cs5/5_5/5_5.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _5_5 + enable + enable + + + diff --git a/cs5/5_5/5_5.sln b/cs5/5_5/5_5.sln new file mode 100644 index 0000000..143db49 --- /dev/null +++ b/cs5/5_5/5_5.sln @@ -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_5", "5_5.csproj", "{C2EFCC00-2BDF-4E39-BBF1-FB54B8CB2708}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C2EFCC00-2BDF-4E39-BBF1-FB54B8CB2708}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C2EFCC00-2BDF-4E39-BBF1-FB54B8CB2708}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C2EFCC00-2BDF-4E39-BBF1-FB54B8CB2708}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C2EFCC00-2BDF-4E39-BBF1-FB54B8CB2708}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {987BE462-C992-48BE-98EB-41564DDA8179} + EndGlobalSection +EndGlobal diff --git a/cs5/5_5/Program.cs b/cs5/5_5/Program.cs new file mode 100644 index 0000000..288fb11 --- /dev/null +++ b/cs5/5_5/Program.cs @@ -0,0 +1,46 @@ +namespace _5_5 +{ + public struct Complex + { + public int real; + public int imag; + public Complex(int r, int i) + { + this.real = r; + this.imag = i; + } + public static Complex operator +(Complex c1, Complex c2) + { + return new Complex(c1.real + c2.real, c1.imag + c2.imag); + } + public static Complex operator -(Complex c1, Complex c2) + { + return new Complex(c1.real - c2.real, c1.imag - c2.imag); + } + public static Complex operator *(Complex c1, Complex c2) + { + return new Complex(c1.real * c2.real - c1.imag * c2.imag, c1.real * c2.imag + c1.imag * c2.real); + } + public override string ToString() + { + return (string.Format("{0}+{1}i", this.real, this.imag)); + } + } + public class Program + { + static void Main(string[] args) + { + Complex c1 = new Complex(2, 3); + Complex c2 = new Complex(4, 5); + Complex sum = c1 + c2; + Complex diff = c1 - c2; + Complex prod = c1 * c2; + Console.WriteLine("第一个复数" + c1); + Console.WriteLine("第二个复数" + c2); + Console.WriteLine("复数的和" + sum); + Console.WriteLine("复数的差" + diff); + Console.WriteLine("复数的积" + prod); + Console.ReadKey(); + } + } +} diff --git a/cs5/5_6/5_6.csproj b/cs5/5_6/5_6.csproj new file mode 100644 index 0000000..7bf04e5 --- /dev/null +++ b/cs5/5_6/5_6.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _5_6 + enable + enable + + + diff --git a/cs5/5_6/5_6.sln b/cs5/5_6/5_6.sln new file mode 100644 index 0000000..32aebe3 --- /dev/null +++ b/cs5/5_6/5_6.sln @@ -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_6", "5_6.csproj", "{93E19541-FEF3-4004-878B-615610904002}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {93E19541-FEF3-4004-878B-615610904002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93E19541-FEF3-4004-878B-615610904002}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93E19541-FEF3-4004-878B-615610904002}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93E19541-FEF3-4004-878B-615610904002}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {49161CD3-DF8F-4571-A2D5-DDDC82BFFCC2} + EndGlobalSection +EndGlobal diff --git a/cs5/5_6/Program.cs b/cs5/5_6/Program.cs new file mode 100644 index 0000000..86d2b3d --- /dev/null +++ b/cs5/5_6/Program.cs @@ -0,0 +1,61 @@ +namespace _5_6 +{ + public interface ICDPlayer + { + void Play(); + void Stop(); + void PreviousTrack(); + void NextTrack(); + int CurrentTrack + { + get; + } + } + public class CDPlayer : ICDPlayer + { + private int currentTrack = 0; + public void Play() + { + Console.WriteLine("启动CD。。。"); + } + public void Stop() + { + Console.WriteLine("停止播放CD。。。"); + } + public void PreviousTrack() + { + if (currentTrack > 0) + { + currentTrack--; + } + Console.WriteLine("上一音轨:"); + } + public void NextTrack() + { + Console.WriteLine("下一音轨:"); + currentTrack++; + } + public int CurrentTrack + { + get + { + return currentTrack; + } + } + } + public class Program + { + static void Main(string[] args) + { + CDPlayer mycd = new CDPlayer(); + mycd.Play(); + Console.WriteLine("当前音轨:" + mycd.CurrentTrack); + mycd.NextTrack(); + Console.WriteLine("当前音轨:" + mycd.CurrentTrack); + mycd.PreviousTrack(); + Console.WriteLine("当前音轨:" + mycd.CurrentTrack); + mycd.Stop(); + + } + } +} diff --git a/cs5/5_7/5_7.csproj b/cs5/5_7/5_7.csproj new file mode 100644 index 0000000..f897b82 --- /dev/null +++ b/cs5/5_7/5_7.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + _5_7 + enable + enable + + + diff --git a/cs5/5_7/5_7.sln b/cs5/5_7/5_7.sln new file mode 100644 index 0000000..5e40685 --- /dev/null +++ b/cs5/5_7/5_7.sln @@ -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_7", "5_7.csproj", "{096FB123-18B3-4727-A914-48480106C798}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {096FB123-18B3-4727-A914-48480106C798}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {096FB123-18B3-4727-A914-48480106C798}.Debug|Any CPU.Build.0 = Debug|Any CPU + {096FB123-18B3-4727-A914-48480106C798}.Release|Any CPU.ActiveCfg = Release|Any CPU + {096FB123-18B3-4727-A914-48480106C798}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {02E74EAC-8A72-404C-B90C-C6C9BFD815B0} + EndGlobalSection +EndGlobal diff --git a/cs5/5_7/Program.cs b/cs5/5_7/Program.cs new file mode 100644 index 0000000..5cf8d1b --- /dev/null +++ b/cs5/5_7/Program.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections; +namespace _5_7 +{ + public class NameListEventArgs : EventArgs + { + public string Name { get; set; } + public int Count { get; set; } + public NameListEventArgs(string name, int count) + { + Name = name; + Count = count; + } + } + public delegate void NameListEventHandler(object source, NameListEventArgs e); + public class NameList + { + ArrayList list; + public event NameListEventHandler nameListEvent; + public NameList() + { + list = new ArrayList(); + } + public void Add(string name) + { + list.Add(name); + if (nameListEvent != null) + { + nameListEvent(this, new NameListEventArgs(name, list.Count)); + } + } + } + public class EventDemo + { + public static void Method1(object source, NameListEventArgs e) + { + Console.WriteLine("增加项目 {0}", e.Name); + } + public static void Method2(object source, NameListEventArgs e) + { + Console.WriteLine("当前项目总数 {0}", e.Count); + } + public static void Main() + { + NameList myList = new NameList(); + myList.nameListEvent += new NameListEventHandler(Method1); + myList.nameListEvent += new NameListEventHandler(Method2); + myList.Add("张三"); + myList.Add("李四"); + myList.Add("王五"); + } + } +} diff --git a/lab/lab.cpp b/lab/lab.cpp new file mode 100644 index 0000000..c6d2ad4 --- /dev/null +++ b/lab/lab.cpp @@ -0,0 +1,192 @@ +#include +#include + +#define TRUE 1 +#define FALSE 0 +#define queuesize 10 +#define maxvernum 8 + +typedef struct queue { + int elements[queuesize]; + int front; + int rear; +} queue; + +// 入队函数 +int enQueue(queue* q, int value) { + if ((q->rear + 1) % queuesize == q->front) { + return FALSE; + } + q->elements[q->rear] = value; + q->rear = (q->rear + 1) % queuesize; + return TRUE; +} + +// 出队函数 +int deQueue(queue* q, int* value) { + if (q->front == q->rear) { + return FALSE; + } + *value = q->elements[q->front]; + q->front = (q->front + 1) % queuesize; + return TRUE; +} + +// 初始化队列 +void initQueue(queue* q) { + q->front = 0; + q->rear = 0; +} + +// 单链表节点定义 +typedef struct Node { + int data; + struct Node* next; +} Node; + +// 顶点结点(邻接表头) +typedef struct VexNode { + int vexnum; + Node* firstedge; +} VexNode; + +// 邻接表 +typedef struct AdjList { + VexNode adjlist[maxvernum]; + int vexnum; + int edgenum; +} AdjList; + +// 定位顶点值 +int locateVex(AdjList* G, int v) { + for (int i = 0; i < G->vexnum; i++) { + if (G->adjlist[i].vexnum == v) { + return i; + } + } + return -1; +} + +// 创建有向图 +void Creategraph(AdjList* g) { + int i, k, v1, v2; + printf("请输入顶点数和边数(空格分隔):", maxvernum); + scanf_s("%d %d", &g->vexnum, &g->edgenum); + + // 初始化顶点 + for (i = 0; i < g->vexnum; i++) { + g->adjlist[i].vexnum = i + 1; + g->adjlist[i].firstedge = NULL; + } + + printf("当前顶点为:"); + for (i = 0; i < g->vexnum; i++) { + printf("v%d ", g->adjlist[i].vexnum); + } + printf("\n"); + + // 依次输入每条有向边(弧头 v1 -> 弧尾 v2),用空格分隔 + for (k = 0; k < g->edgenum; k++) { + printf("请输入第%d条有向边的弧头 和 弧尾(用空格分隔):", k + 1); + scanf_s("%d %d", &v1, &v2); + int i_idx = locateVex(g, v1); + int j_idx = locateVex(g, v2); + if (i_idx >= 0 && j_idx >= 0) { + // 在 v1 的链表末尾加入 v2 + Node* bss = (Node*)malloc(sizeof(Node)); + if (!bss) { + printf("内存分配失败"); + return; + } + bss->data = v2; + bss->next = NULL; + if (g->adjlist[i_idx].firstedge == NULL) { + g->adjlist[i_idx].firstedge = bss; + } + else { + Node* q = g->adjlist[i_idx].firstedge; + while (q->next) q = q->next; + q->next = bss; + } + } + else { + printf("顶点 %d 或 %d 不存在,边被忽略\n", v1, v2); + } + } + + // 输出邻接表 + printf("输出各个顶点的邻接表:\n"); + for (i = 0; i < g->vexnum; i++) { + printf("顶点 v%d", g->adjlist[i].vexnum); + Node* p = g->adjlist[i].firstedge; + while (p) { + printf(" --> v%d", p->data); + p = p->next; + } + printf("\n"); + } +} + +// 深度优先遍历 +void DFS(AdjList* G, int v, int visited[]) { + int i = locateVex(G, v); + visited[i] = 1; + printf("%d ", G->adjlist[i].vexnum); + Node* p = G->adjlist[i].firstedge; + while (p != NULL) { + int j = locateVex(G, p->data); + if (j != -1 && !visited[j]) { + DFS(G, p->data, visited); + } + p = p->next; + } +} + +// 广度优先遍历 +void BFS(AdjList* G, int v, int visited[]) { + queue q; + initQueue(&q); + int i = locateVex(G, v); + if (i == -1) return; + visited[i] = 1; + printf("%d ", G->adjlist[i].vexnum); + enQueue(&q, v); + int w; + while (deQueue(&q, &w)) { + int k = locateVex(G, w); + if (k == -1) continue; + Node* p = G->adjlist[k].firstedge; + while (p != NULL) { + int j = locateVex(G, p->data); + if (j != -1 && !visited[j]) { + visited[j] = 1; + printf("%d ", G->adjlist[j].vexnum); + enQueue(&q, p->data); + } + p = p->next; + } + } +} + +int main() { + AdjList G; + Creategraph(&G); + int visited[maxvernum] = { 0 }; + printf("深度优先遍历结果:"); + for (int i = 0; i < G.vexnum; i++) { + if (!visited[i]) { + DFS(&G, G.adjlist[i].vexnum, visited); + } + } + printf("\n"); + + for (int i = 0; i < maxvernum; i++) visited[i] = 0; + printf("广度优先遍历结果:"); + for (int i = 0; i < G.vexnum; i++) { + if (!visited[i]) { + BFS(&G, G.adjlist[i].vexnum, visited); + } + } + + return 0; +} diff --git a/lab/lab.sln b/lab/lab.sln new file mode 100644 index 0000000..edc561f --- /dev/null +++ b/lab/lab.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lab", "lab.vcxproj", "{5D999FD0-2593-4479-ADDA-A7FAAEFDF13E}" +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 + {5D999FD0-2593-4479-ADDA-A7FAAEFDF13E}.Debug|x64.ActiveCfg = Debug|x64 + {5D999FD0-2593-4479-ADDA-A7FAAEFDF13E}.Debug|x64.Build.0 = Debug|x64 + {5D999FD0-2593-4479-ADDA-A7FAAEFDF13E}.Debug|x86.ActiveCfg = Debug|Win32 + {5D999FD0-2593-4479-ADDA-A7FAAEFDF13E}.Debug|x86.Build.0 = Debug|Win32 + {5D999FD0-2593-4479-ADDA-A7FAAEFDF13E}.Release|x64.ActiveCfg = Release|x64 + {5D999FD0-2593-4479-ADDA-A7FAAEFDF13E}.Release|x64.Build.0 = Release|x64 + {5D999FD0-2593-4479-ADDA-A7FAAEFDF13E}.Release|x86.ActiveCfg = Release|Win32 + {5D999FD0-2593-4479-ADDA-A7FAAEFDF13E}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AD21B75E-63D4-4614-872B-9EBA69D211F0} + EndGlobalSection +EndGlobal diff --git a/lab/lab.vcxproj b/lab/lab.vcxproj new file mode 100644 index 0000000..933cb25 --- /dev/null +++ b/lab/lab.vcxproj @@ -0,0 +1,131 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {5d999fd0-2593-4479-adda-a7faaefdf13e} + lab + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + + + + + \ No newline at end of file diff --git a/lab/lab.vcxproj.filters b/lab/lab.vcxproj.filters new file mode 100644 index 0000000..5ab5c71 --- /dev/null +++ b/lab/lab.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 源文件 + + + \ No newline at end of file diff --git a/shiyan3/shiyan3.cpp b/shiyan3/shiyan3.cpp new file mode 100644 index 0000000..79b5075 --- /dev/null +++ b/shiyan3/shiyan3.cpp @@ -0,0 +1,159 @@ +#include +#include + +typedef struct Tree { + char data; + struct Tree *lchild; + struct Tree *rchild; +} Tree; + +// 初始化树 +void initTree(Tree *T) { + T->lchild = NULL; + T->rchild = NULL; + T->data = '0'; +} + +// 创建树 +void CreateTree(Tree* T) { + int n = 0, m = 0, i = 0; + if (T->data == '0') { + printf("请输入该子树根节点的数据:"); + //getchar(); + //char x; + scanf_s("%c", &T->data); + getchar(); + } + + printf("节点%c是否有左子树(0:没有;1:有):", T->data); + scanf_s("%d", &n); + getchar(); + + if (n == 1) { + Tree* lchild = (Tree*)malloc(sizeof(Tree)); + T->lchild = lchild; + lchild->lchild = NULL; + lchild->rchild = NULL; + lchild->data = '0'; + CreateTree(T->lchild); + + printf("该节点%c是否存在右子树(0:没有; 1:有):", T->data); + scanf_s("%d", &i); + getchar(); + + if (i == 1) { + Tree* rchild = (Tree*)malloc(sizeof(Tree)); + T->rchild = rchild; + rchild->lchild = NULL; + rchild->rchild = NULL; + rchild->data = '0'; + CreateTree(T->rchild); + } + } + else if (n == 0) { + printf("节点%c是否有右子树(0:没有;1:有):", T->data); + scanf_s("%d", &m); + getchar(); + + if (m == 1) { + Tree* rchild = (Tree*)malloc(sizeof(Tree)); + T->rchild = rchild; + rchild->lchild = NULL; + rchild->rchild = NULL; + rchild->data = '0'; + CreateTree(T->rchild); + } + } +} + +// 中序遍历 +void LDR(Tree *T) { + if (T != NULL) { + LDR(T->lchild); + printf("%c ", T->data); + LDR(T->rchild); + } +} + +// 先序遍历 +void DLR(Tree *T) { + if (T != NULL) { + printf("%c ", T->data); + DLR(T->lchild); + DLR(T->rchild); + } +} + +// 后序遍历 +void LRD(Tree *T) { + if (T != NULL) { + LRD(T->lchild); + LRD(T->rchild); + printf("%c ", T->data); + } +} + +// 计算叶子节点个数 +int leaves(Tree *T) { + int count = 0; + if (T == NULL) { + return 0; + } + if (T->lchild == NULL && T->rchild == NULL) { + count ++; + } else { + return leaves(T->lchild) + leaves(T->rchild); + } + return count; +} + +// 计算树的深度 +int depth(Tree *T) { + int ldepth = 0, rdepth = 0; + if (T == NULL) { + return 0; + } else { + ldepth = depth(T->lchild); + rdepth = depth(T->rchild); + return (ldepth > rdepth) ? (ldepth + 1) : (rdepth + 1); + } +} + +// 计算树的节点个数 +int nodes(Tree *T) { + if (T == NULL) { + return 0; + } else { + return nodes(T->lchild) + nodes(T->rchild) + 1; + } +} + +// 计算度为2的节点个数 +int degree2nodes(Tree *T) { + int count = 0; + if (T == NULL) { + return 0; + } + if (T->lchild != NULL && T->rchild != NULL) { + count ++; + } + return count + degree2nodes(T->lchild) + degree2nodes(T->rchild); +} + +int main() { + Tree bss; + initTree(&bss); + + CreateTree(&bss); + printf("中序遍历结果为:\n"); + LDR(&bss); + printf("\n先序遍历结果为:\n"); + DLR(&bss); + printf("\n后序遍历结果为:\n"); + LRD(&bss); + printf("\n叶子节点个数为:%d\n", leaves(&bss)); + printf("树的深度为:%d\n", depth(&bss)); + printf("树的节点个数为:%d\n", nodes(&bss)); + printf("度为2的节点个数为:%d\n", degree2nodes(&bss)); + return 0; +} \ No newline at end of file diff --git a/shiyan3/shiyan3.sln b/shiyan3/shiyan3.sln new file mode 100644 index 0000000..e2a5b69 --- /dev/null +++ b/shiyan3/shiyan3.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shiyan3", "shiyan3.vcxproj", "{EDB604AC-AC4B-44E1-9CC6-94E4D3B90D25}" +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 + {EDB604AC-AC4B-44E1-9CC6-94E4D3B90D25}.Debug|x64.ActiveCfg = Debug|x64 + {EDB604AC-AC4B-44E1-9CC6-94E4D3B90D25}.Debug|x64.Build.0 = Debug|x64 + {EDB604AC-AC4B-44E1-9CC6-94E4D3B90D25}.Debug|x86.ActiveCfg = Debug|Win32 + {EDB604AC-AC4B-44E1-9CC6-94E4D3B90D25}.Debug|x86.Build.0 = Debug|Win32 + {EDB604AC-AC4B-44E1-9CC6-94E4D3B90D25}.Release|x64.ActiveCfg = Release|x64 + {EDB604AC-AC4B-44E1-9CC6-94E4D3B90D25}.Release|x64.Build.0 = Release|x64 + {EDB604AC-AC4B-44E1-9CC6-94E4D3B90D25}.Release|x86.ActiveCfg = Release|Win32 + {EDB604AC-AC4B-44E1-9CC6-94E4D3B90D25}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B9410CB9-2A4A-4538-BEB4-3EE6716DD001} + EndGlobalSection +EndGlobal diff --git a/shiyan3/shiyan3.vcxproj b/shiyan3/shiyan3.vcxproj new file mode 100644 index 0000000..4d4e14b --- /dev/null +++ b/shiyan3/shiyan3.vcxproj @@ -0,0 +1,131 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {edb604ac-ac4b-44e1-9cc6-94e4d3b90d25} + shiyan3 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + + + + + \ No newline at end of file diff --git a/shiyan3/shiyan3.vcxproj.filters b/shiyan3/shiyan3.vcxproj.filters new file mode 100644 index 0000000..1d30267 --- /dev/null +++ b/shiyan3/shiyan3.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 源文件 + + + \ No newline at end of file diff --git a/shiyan3/作业7.cpp b/shiyan3/作业7.cpp new file mode 100644 index 0000000..79b5075 --- /dev/null +++ b/shiyan3/作业7.cpp @@ -0,0 +1,159 @@ +#include +#include + +typedef struct Tree { + char data; + struct Tree *lchild; + struct Tree *rchild; +} Tree; + +// 初始化树 +void initTree(Tree *T) { + T->lchild = NULL; + T->rchild = NULL; + T->data = '0'; +} + +// 创建树 +void CreateTree(Tree* T) { + int n = 0, m = 0, i = 0; + if (T->data == '0') { + printf("请输入该子树根节点的数据:"); + //getchar(); + //char x; + scanf_s("%c", &T->data); + getchar(); + } + + printf("节点%c是否有左子树(0:没有;1:有):", T->data); + scanf_s("%d", &n); + getchar(); + + if (n == 1) { + Tree* lchild = (Tree*)malloc(sizeof(Tree)); + T->lchild = lchild; + lchild->lchild = NULL; + lchild->rchild = NULL; + lchild->data = '0'; + CreateTree(T->lchild); + + printf("该节点%c是否存在右子树(0:没有; 1:有):", T->data); + scanf_s("%d", &i); + getchar(); + + if (i == 1) { + Tree* rchild = (Tree*)malloc(sizeof(Tree)); + T->rchild = rchild; + rchild->lchild = NULL; + rchild->rchild = NULL; + rchild->data = '0'; + CreateTree(T->rchild); + } + } + else if (n == 0) { + printf("节点%c是否有右子树(0:没有;1:有):", T->data); + scanf_s("%d", &m); + getchar(); + + if (m == 1) { + Tree* rchild = (Tree*)malloc(sizeof(Tree)); + T->rchild = rchild; + rchild->lchild = NULL; + rchild->rchild = NULL; + rchild->data = '0'; + CreateTree(T->rchild); + } + } +} + +// 中序遍历 +void LDR(Tree *T) { + if (T != NULL) { + LDR(T->lchild); + printf("%c ", T->data); + LDR(T->rchild); + } +} + +// 先序遍历 +void DLR(Tree *T) { + if (T != NULL) { + printf("%c ", T->data); + DLR(T->lchild); + DLR(T->rchild); + } +} + +// 后序遍历 +void LRD(Tree *T) { + if (T != NULL) { + LRD(T->lchild); + LRD(T->rchild); + printf("%c ", T->data); + } +} + +// 计算叶子节点个数 +int leaves(Tree *T) { + int count = 0; + if (T == NULL) { + return 0; + } + if (T->lchild == NULL && T->rchild == NULL) { + count ++; + } else { + return leaves(T->lchild) + leaves(T->rchild); + } + return count; +} + +// 计算树的深度 +int depth(Tree *T) { + int ldepth = 0, rdepth = 0; + if (T == NULL) { + return 0; + } else { + ldepth = depth(T->lchild); + rdepth = depth(T->rchild); + return (ldepth > rdepth) ? (ldepth + 1) : (rdepth + 1); + } +} + +// 计算树的节点个数 +int nodes(Tree *T) { + if (T == NULL) { + return 0; + } else { + return nodes(T->lchild) + nodes(T->rchild) + 1; + } +} + +// 计算度为2的节点个数 +int degree2nodes(Tree *T) { + int count = 0; + if (T == NULL) { + return 0; + } + if (T->lchild != NULL && T->rchild != NULL) { + count ++; + } + return count + degree2nodes(T->lchild) + degree2nodes(T->rchild); +} + +int main() { + Tree bss; + initTree(&bss); + + CreateTree(&bss); + printf("中序遍历结果为:\n"); + LDR(&bss); + printf("\n先序遍历结果为:\n"); + DLR(&bss); + printf("\n后序遍历结果为:\n"); + LRD(&bss); + printf("\n叶子节点个数为:%d\n", leaves(&bss)); + printf("树的深度为:%d\n", depth(&bss)); + printf("树的节点个数为:%d\n", nodes(&bss)); + printf("度为2的节点个数为:%d\n", degree2nodes(&bss)); + return 0; +} \ No newline at end of file