您的位置:首页 > 理论基础 > 数据结构算法

链表的实现与原理

2016-07-10 15:37 211 查看
</pre>    链表是一种线性表,是通过指针与数据综合的组成的一种数据结构。可分为单链表与双链表</p><p>    链表的创建:</p><p>    <pre name="code" class="cpp">#include <iostream>
using namespace std;

struct Node
{
ELEM data;
Node* next;
};

Node* creatList( int n )
{
Node* head, * tail, * temp;
head=NULL;
tail=NULL;
ELEM datetemp;
for(int i=0;i<n;i++)
{
temp = new Node;
cin>>datatemp;
temp=datatemp;
if(head==NULL)
{
tail=head=temp;
}
else
{
tail->next=temp;
tail=temp;
}
}
return head;
}

int main()
{
//TO DO for test
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  数据结构