the data struct on DulLinkList
来源:互联网 发布:淘宝小西装 编辑:程序博客网 时间:2024/05/19 06:51
// copyright vinco zhang
#include<stdio.h>
typedef int ElemType;
typedef struct DulNode
{
ElemType data;
struct DulNode *prior,*next;
}DulNode,* DulLinkList;
//typedef struct DulNode* DulLinkList;
//#define DulLinkList struct DulNode*
/******************************************/
void Insert_DuLink_i(DulLinkList p, int x);
void Insert_DuLink_x(DulLinkList p, int x);
void Delete_DuLink(DulLinkList p);
DulLinkList Create_DuLink_H(int n);
DulLinkList Create_DuLink_T(int n);
void print_DuLink(DulLinkList L);
/******************************************/
int main()
{
int n;
DulLinkList L;
printf("/ninput the length of the DulLinkList n=");
scanf("%d",&n);
L = Create_DuLink_H(n);
//print_DuLink(L);
return 0;
}
/******************************************/
void Insert_DuLink_i(DulLinkList p, int i)
{
}
void Insert_DuLink_x(DulLinkList p, int x)
{
DulLinkList s;
s=(DulLinkList)malloc(sizeof(DulNode));
s->data=x;
s->prior = p->prior ;
p->prior->next = s;
s->next=p;
p->prior = s;
}
void Delete_DuLink(DulLinkList p)
{
p->prior->next = p->next;
p->next->prior = p->prior;
free(p);
}
DulLinkList Create_DuLink_H(int n)// insert into the behind of head node everytime
{
int i;
DulLinkList L = (DulLinkList)malloc(sizeof(DulNode));
if(L==NULL)
{
printf("error when creating head node!/n");
return NULL;
}
L->prior = NULL;
L->next = NULL;
for(i=1;i<=n;i++)
{
DulLinkList s = (DulLinkList)malloc(sizeof(DulNode));
if(s==NULL)
{
printf("error when creating %d node!/n",i);
return L;
}
printf("please input the data of the node:index=%d data=",i);
scanf("%d",&(s->data));
s->next = L->next;
L->next = s;
if(s->next)
{
s->next->prior=s;
s->prior=L;
}
else
{
s->prior=L;
}
}
print_DuLink(L);
return L;
}
DulLinkList Create_DuLink_T(int n)
{
int i;
DulLinkList L = (DulLinkList)malloc(sizeof(DulNode));
DulLinkList p = L;
if(L==NULL)
{
printf("error when creating head node!/n");
return NULL;
}
L->prior = NULL;
L->next = NULL;
for(i=1;i<=n;i++)
{
DulLinkList s = (DulLinkList)malloc(sizeof(DulNode));
if(s==NULL)
{
printf("error when creating %100d node!/n",i);
return L;
}
printf("please input the data of the %10d node:/n",i);
scanf("%d",&(s->data));
s->next = NULL;
s->prior =p;
p->next = s;
p = s;
p->next =NULL;
}
return L;
}
void print_DuLink(DulLinkList L)
{
int i=0;
DulLinkList p=L;
while(p->next!=NULL)
{
i++;
printf("index=%d L->data=%d/n",i,L->data );
p=p->next ;
}
}
参考资料
《数据结构(C语言)》
- the data struct on DulLinkList
- 2.the data struct on DulLinkList
- the data struct on LinkList
- 2. the data struct on LinkList
- Data on the Outside vs. Data on the Inside
- Data on the Outside vs. Data on the Inside(译)
- Data Mining on the Web
- STRUCT DATA
- Data Struct
- similarity search on complex data : the direction
- SQL tree data struct(7): find the minimal cost route
- calculate and return the accuracy on the test data
- Designing Data Storage Architecture-the data storage offerings available on the Windows Azure platfo
- CTreeCtrl/CListCtrl/CListBox With ToolTip Based On the Item Data
- Spatial Data on the Web: Modeling and Management
- XMLDM: The Third International Workshop on XML Data Management
- How to display the data from database on JTable
- Proceedings of the Tenth SIAM International Conference on Data Mining
- Session和Cookie的区别
- 原子访问--- Interlocked系列函数
- netty的个人使用心得
- 读李战的《悟透JAVASCRIPT 美绘本》有感
- win7使用telnet命令
- the data struct on DulLinkList
- PANOSE
- printf 格式对齐
- SecureCRT 乱码解决
- 转: 框架
- 查看LINUX 硬件配置信息
- SQL随机查询
- XML语言包
- VC++ MFC DLL动态链接库编写详解