链表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace list
{
class Program
{
static void Main(string[] args)
{
LinkedList<int> LinkList;
List<LinkedListNode<int>> Lnode;
LinkList = new LinkedList<int>();
Lnode = new List<LinkedListNode<int>>();
Lnode.Add(new LinkedListNode<int>(3));
Lnode.Add(new LinkedListNode<int>(1));
Lnode.Add(new LinkedListNode<int>(2));
LinkList.AddFirst(Lnode[2]);
LinkList.AddBefore(Lnode[2],Lnode[1]);
LinkList.AddAfter(Lnode[2],Lnode[0]);
foreach (int doc in LinkList)
{
Console.WriteLine(doc);
}
}
}
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections;
using System.Linq;
using System.Text;
namespace stack
{
class Program
{
static void Main(string[] args)
{
Stack st = new Stack();
st.Push('A');
st.Push('B');
Console.WriteLine(st.Pop());
st.Push('C');
Console.WriteLine(st.Pop());
Console.WriteLine(st.Count);
Console.WriteLine(st.Pop());
st.Push('D');
Console.WriteLine(st.Pop());
}
}
}

队列

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Collections;
using System.Linq;
using System.Text;
namespace stack
{
class Program
{
static void Main(string[] args)
{
Queue q = new Queue{};
for (int i = 0; i < 10; i++)
{
q.Enqueue(i);
}
foreach (int p in q)
{
Console.WriteLine(p);
}
}
}
}