1. 程式人生 > 其它 >python 的 xlrd模組 讀取Excel

python 的 xlrd模組 讀取Excel

單鏈表

class Program
{
    static void Main(string[] args)
    {
        LinkedList<int> linkedList = new LinkedList<int>();
        Node<int> node1 = new Node<int> { Data = 1 };
        Node<int> node2 = new Node<int> { Data = 2 };
        Node<int> node3 = new
Node<int> { Data = 3 }; Node<int> node4 = new Node<int> { Data = 4 }; linkedList.Append(node1); linkedList.Append(node2); linkedList.Append(node3); linkedList.Append(node4); linkedList.Insert(4, new Node<int> { Data = 0 }); linkedList.Delete(
2); linkedList.Display(); //int length = linkedList.GetLength(); //Console.WriteLine(length); Console.WriteLine(linkedList.GetDataByIndex(0).Data); Console.ReadKey(); } } class LinkedList<T> { public Node<T> Head { get; set; } public LinkedList() { Head
= null; } #region 新增 public void Append(Node<T> node) { Node<T> foot = node; if (Head == null) { Head = foot; return; } Node<T> A = Head; while (A.Next != null) { A = A.Next; } A.Next = foot; } #endregion #region 插入 public void Insert(int index, Node<T> node) { if (Head == null || index > GetLength()) return; if (index == 0) { Node<T> temp = Head; Head = node; Head.Next = temp; return; } //Node<T> previous = GetDataByIndex(index - 1); //node.Next = previous.Next; //previous.Next = node; Node<T> A = new Node<T>(); Node<T> B = new Node<T>(); B = Head; int j = 0; while (j < index) { A = B; B = B.Next; j++; } if (j == index) { Node<T> C = node; A.Next = C; C.Next = B; } } #endregion #region 刪除 public void Delete(int index) { if (Head == null || index >= GetLength()) return; if (index == 0) { Head = Head.Next; return; } //Node<T> previous = GetDataByIndex(index - 1); //previous.Next = previous.Next.Next; Node<T> A = new Node<T>(); Node<T> B = Head; int j = 0; while (B.Next != null && j < index) { A = B; B = B.Next; j++; } if (j == index) A.Next = B.Next; } #endregion #region 索引獲取節點 public Node<T> GetDataByIndex(int index) { if (index >= GetLength() || index < 0) { throw (new Exception("length out of range")); } if (index == 0) return Head; int count = 0; Node<T> temp = Head; while (temp.Next != null && count < index) { temp = temp.Next; count++; } return temp; } #endregion #region 長度 public int GetLength() { if (Head == null) return 0; int length = 1; Node<T> A = Head; while (A.Next != null) { A = A.Next; length++; } return length; } #endregion #region 列印 public void Display() { if (Head == null) return; Node<T> temp = Head; while (temp != null) { Console.WriteLine(temp.Data); temp = temp.Next; } } #endregion } class Node<T> { public T Data { get; set; } public Node<T> Next { get; set; } public Node(T item) { this.Data = item; this.Next = null; } public Node() { this.Data = default(T); this.Next = null; } }

把圈子變小,把語言變乾淨,把成績往上提,把故事往心裡收,現在想要的以後你都會有。