#include <iostream>
using namespace std;
struct node
{
int data;
node* first;
node* second;
};
node* Creat()
{
node* head,*p1,*p2;
int m,n;
cout<<"please input your data"<<endl;
head=(node*)malloc(sizeof(node));
if(cin>>m)
head->data=m;
else
{
cout<<"wrong"<<endl;
return NULL;
}
head->first=NULL;
p1=head;
while(cin>>n)
{
p2=(node*)malloc(sizeof(node));
p2->data=n;
p2->first=p1;
p1->second=p2;
p1=p2;
}
p1->second=NULL;
return head;
}
创建双链表
最新推荐文章于 2024-02-16 12:37:24 发布