首页 > 其他 > 详细

双链表的建立

时间:2015-08-02 21:36:39      阅读:231      评论:0      收藏:0      [点我收藏+]
技术分享创建双链表
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<conio.h>
using namespace std;


typedef struct student
{
int data;
struct student *next;
struct student *pre;
} dnode;


dnode *create()
{
dnode *head, *p, *s;
int x, cycle = 1;
head = (dnode*)malloc(sizeof(dnode));
p = head;
while (cycle)
{
printf("\nplease input the data:");
scanf("%d", &x);
if (x != 0)
{
s = (dnode*)malloc(sizeof(dnode));
s->data = x;
printf("\n %d", s->data);
p->next = s;
s->pre = p;
p = s;
}
else
cycle = 0;
}
head = head->next;
head->pre = NULL;
p->next = NULL;
printf("\n  yyy %d", head->data);
return (head);
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

双链表的建立

原文:http://blog.csdn.net/wangfengfan1/article/details/47211227

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!