• 双链表


    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;
        }
    };
  • 相关阅读:
    P1579哥德巴赫猜想
    JAVA快速入门方法
    PHP快速入门方法
    Java 8 lambda表达式
    JVM内存配置参数
    Synchronized 关键字
    数据库事务的理解
    hello world 执行原理
    面试知识点总结之JVM调优
    面试知识点总结之RabbitMQ/Kafka使用场景
  • 原文地址:https://www.cnblogs.com/candycloud/p/3341516.html
Copyright © 2020-2023  润新知