30 lines
799 B
C#
30 lines
799 B
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|