添加Lesson10

This commit is contained in:
2025-10-15 09:45:51 +08:00
parent 47193206ac
commit 58e0a25def
5 changed files with 160 additions and 0 deletions
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
@@ -0,0 +1,29 @@
namespace Lesson10_LinkedList练习
{
class Program
{
static void Main(string[] args)
{
LinkedList<int> ints = new LinkedList<int>();
Random r = new Random();
for (int i = 0; i < 10; i++)
{
ints.AddLast(r.Next(1,100));
}
LinkedListNode<int> temp = ints.First;
while (temp != null)
{
Console.Write(temp.Value + " ");
temp = temp.Next;
}
Console.WriteLine();
Console.WriteLine("----------------");
temp = ints.Last;
while (temp != null)
{
Console.Write(temp.Value + " ");
temp = temp.Previous;
}
}
}
}