zoukankan      html  css  js  c++  java
  • 关于链表创建

    22 void newList(node & head,int length){
    23     node *a=new node[length];//这是这个函数的解释node* operator [] (int n)P11行 申请空间的方式 new int[10]申请10个int类型的空间 再返回node指针类型
    24     for(int i=0;i<length;++i)cin>>a[i].data>>a[i].index;
    25          //a是node类型数组啊
    26     sort(a,a+length);//p16行的函数解释
    27     node* end=&head;
    28     for(int i=0;i<length;++i){
    29         node* t=new node;
    30         t->data=a[i].data;
    31         t->index=a[i].index;
    32         end->next=t;
    33         end=t;
    34     }//他这好像就特别简单 end=xx  之后就申请了新节点 赋值 然后挂上去
    35     delete[] a;
    36 }
    void Create(Node *head)
    { //头插法,创建单链表
     int x;
     while(cin>>x)
     {
         if(x==0)break;
         Node *t=new Node;
         t->data=x;t->next=head->next;
         head->next=t;
     }
    
    }

    我有点慌。。。。

  • 相关阅读:
    FileWatcher
    virtual table(有180个评论)
    this 指针
    docker -ce(社区免费版)
    vue-cli
    CAP理论、BASE理论
    B+树和LSM存储引擎代表树和B-树
    CPU高速缓存
    Python&基础环境搭建
    二叉树
  • 原文地址:https://www.cnblogs.com/yundong333/p/11044553.html
Copyright © 2011-2022 走看看