static void Main(string[] args) { LinkList <int> lin = new LinkList <int>(); lin.Add(1); lin.Add(2); lin.Add(3); lin.Add(4); lin.Add(5); lin.Add(6); lin.Add(7); Console.WriteLine("链表的长度为: " + lin.GetLength()); Console.WriteLine(); Console.Write("链表的元素有: "); for (int i = 0; i < lin.GetLength(); i++) { Console.Write(lin[i] + " "); } Console.Write("第五个是"); Console.WriteLine(lin.GetEle(5)); Console.ReadLine(); }
static void Main(string[] args) { LinkList <string> link = new LinkList <string>(); link.Append("123"); link.Append("567"); link.Append("jqk"); link.Insert("abc", 2); link.InsertPost("def", 2); int length = link.GetLength(); int k = link.Locate("567"); string m = link.GetElem(3); Console.WriteLine("567的位置为" + k); Console.WriteLine("位置为3的值为" + m); Console.WriteLine("链表的长度为" + length); Node <string> n = link.Head; while (n != null) { Console.WriteLine(n.Data); n = n.Next; } }