C 数据结构 实现插入删除循环
typedef datatype;
typedef struct link_node
{
datatype info;
struct link_node *next;
}node;
void printflink(node *head)
{
node *p;
int n=0;
while(p->next != NULL)
{
printf("%5d",p->next->info);
p= p->next;
n++;
if(n%5==0)
printf("\n");
}
}
node *createlink(node *head)
{
node *p,*q;
int flag=1,n;
head->next=NULL;
q=head;
bb:printf("input a info between -32768--32767 you want,input Enter between two info !\nThen put int ZERO(0) to finish:\n");
while(flag)
{
scanf("%d",&n);
if(n<-32767||n>32767)
{
printf("the info you insert may be too big or too small !!\n");
goto bb;
}
else{
if(n!=0)
{
p=(node*)malloc(sizeof(node));
p->info=n;
p->next=NULL;
q->next=p;
q =p;
p = p->next;
}
else
flag=0;
}
}
return head;
}
node *insert(node *head)
{
int n;
int flag=1;
printf(" Insert data you want !youcan insert one,two,OR any more you want,\n input Enter between every two info,and then input ZERO(0)TO finish:\n");
while(flag)
{
node *p=head,*q;
scanf("%d",&n);
if(n!=0)
{
q=(node*)malloc(sizeof(node));
q->info=n;
q->next=p->next;
p->next=q;
}
else flag=0;
}
return head;
}
node *dellink(node *head)
{
int x;
node *pre=head,*q;
printf("\ninsert a info you want to delete!:\n");
scanf("%d",&x);
q=head->next;
while(q&&q->info!=x)
{
pre=q;q=q->next;
}
if(q->info==x)
{
pre->next=q->next;
free(q);
printf("\n the data of this link is:\n");
}
else
printf("\n !!!the link do not have this info!!!!!\n\n");
return head;
}
node *asclink(node *head,int n )
{
int i,j;
node *p,*q;
p=head->next;
q=p->next;
for(i=n;i>1;i--)
{
for(j=1;j<n;j++)
{
if((p->info)>(q->info))
{
int t;t=p->info;
p->info=q->info;
q->info=t;
p=q;
q=q->next;
}
else
{p=q;q=q->next;}
}
p=head->next;
q=p->next;
}
return head;
}
int returnI(node *head)
{
int i=0;
node *q=head;
while(q->next != NULL)
{
q = q->next;
i++;
}
return i;
}
void ReInsert(node *head,char m)
{
char n;
printf("\n Do you want to insert any info ? Please input 'y' or 'n':");
n=scanf("%d",&n);
while((n=getchar())==m)
{
if(n==m)
{
insert(head);
asclink(head,returnI(head));
printf("\n the data of this link is:\n");
printflink(head);
}
printf("\n Do you want to insert any info ? Please input 'y' or 'n':");
n=scanf("%d",&n);
}
}
void main
数据结构实验 建立双向循环链表以及插入删除操作_计算机软件及应用_IT/计算机_专业资料。要求:①建立双向循环链表 ②实现链表的插入、删除...
关键词:数据结构循环链表代码插入和删除 1/2 相关文档推荐 数据结构 顺序表,链表源代... 27页 5财富值 数据结构顺序链表的实现源... 6页 2财富值 c语言...
数据结构单链表及插入删除C语言_计算机软件及应用_IT/计算机_专业资料。数据结构单链表及插入删除C语言数据结构单链表及插入删除 C 语言 #include<stdio.h> #...
3、熟练掌握单链表的插入、删除和修改等算法的设计与 C 语言实现。单链表的插入、删除、合并等基本操作一、实验目的 1、理解数据结构中单链表的定义和建立。 2、...
数据结构C语言实现顺序表的插入和删除代码 隐藏>> #define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define INFEASIBLE -1 #define OVERFLOW...
数据结构中的,线性表的c语言表示和插入,删除,查找操作程序_IT/计算机_专业... 数据结构C语言实现系列—... 13页 免费 第2章:线性表 数据结构... 67页...
1、顺序线性表中元素的插入 2、顺序线性表中元素的删除 3、顺序线性表中元素的查找(顺序查找) 各种操作的实现算法《C语言与数据结构》 教学目标 教学重点 教学...
数据结构C语言实现顺序表的... 3页 2财富值喜欢此文档的还喜欢... 帮我用C语言写一个数据结构中单链表的建立和插入以及删除操作 隐藏>> 帮我...
数据结构C语言版 循环链表表示和实现_经管营销_专业资料。你心目中的“小王子...(p==*L) // 改变尾结点 *L=s; return 1; } // 删除L的第i个元素,...
C语言实现的循环链表排序 插入 删除结点_计算机软件及应用_IT/计算机_专业资料。用C语言实现的循环链表创建 遍历 删除增加结点,排序,编译通过的程序。...
热门文档