双链表的尾插法建立输出

来源:互联网 发布:淘宝店铺改名字 编辑:程序博客网 时间:2024/06/17 00:42
struct node{    int id;    char name[32];    node* next;    node* prior;};node* head;int len;void creat(){    head=new node;    head->prior=NULL;    head->next=NULL;    node* r=head;    int x;    char name[32];    for(int i=0;i<len;i++)    {        cin>>x;        cin>>name;        node* p=new node;        p->id=x;        strcpy(p->name,name);        r->next=p;        p->prior=r;        r=p;    }    r->next=NULL;}void show(){    node* p=head->next;    while(p)    {        cout<<p->id<<p->name<<endl;        p=p->next;    }    cout<<endl;}

原创粉丝点击