zoukankan      html  css  js  c++  java
  • 双链表

    struct node{
      int Data;
      node *pre;
      node *next;
    };
     
    class linklist{
      private:
      node *head;
      node *end;
      public:
        linklist(int D,int d){
          head = new node;
          end = new node;
          head->pre = NULL;
          head->Data = D;
          head->next = end;
          end->pre = head;
          end->Data = d;
          end->next = NULL;
        }
     
        void print(){
          node *m = head;
          while(m->next != NULL){
            cout<<m->Data<<endl;
            m = m->next;
          }
          cout<<m->Data<<endl;
        }
     
        void Insert_from_head(int D){
          node *a = new node;
          a->next = head->next;
          a->Data = head->Data;
          a->pre = head;
          head->next = a;
          head->Data = D;
        }
        void Insert_from_end(int D){
          node *a = new node;
          end->pre->next = a;
          a->next = end;
          a->Data = end->Data;
          a->pre = end->pre;
          end->pre = a;
          end->Data = D;
        }
    };
  • 相关阅读:
    Window.ActiveXObject的用法 以及如何判断浏览器的类型
    PDO预处理
    *p=&a是把a的值赋给p,p=&a是把a的地址赋给p。
    牛客网
    关于stable_sort()和sort()的区别
    求最小公倍数
    成绩排序
    二叉树的存储、创建以及遍历
    关于sort函数的几种用法
    vector的用法
  • 原文地址:https://www.cnblogs.com/candycloud/p/3341516.html
Copyright © 2011-2022 走看看