Weitere ähnliche Inhalte
Ähnlich wie Linked list searching deleting inserting (20)
Mehr von Samsil Arefin (20)
Kürzlich hochgeladen (20)
Linked list searching deleting inserting
- 1. #include <stdio.h>
#include <stdlib.h>
typedef struct list{
int v;
struct list * n;
}h;
h*cr()
{
return (h*)malloc(sizeof(h));
}
void insert(h*t,int data){
while(t->n!=NULL)
{
t=t->n;
}
t->n=cr();
t->n->v=data;
t->n->n=NULL;
}
void dis(h*t)
{
while(t->n!=NULL)
- 3. if(t->n->v == search)
{
h *store = t->n->n;
t->n->n = cr();
t->n->n->v = data;
t->n->n->n = store;
}
t=t->n;
}
}
int del(h *t, int data)
{
while(t->n != NULL)
{
if(t->n->v == data)
{
t->n = t->n->n;
return 0;
}
t = t->n;
}
}
- 4. void countNode(h *t)
{
int count = 0;
while(t->n != NULL)
{
count++;
t = t->n ;
}
printf("nTotal %d nodes found.n", count);
}
int main()
{
h*f=cr();
f->n=NULL;
insert(f, 5);
insert(f, 9);
insert(f, 11);
insert(f, 9);
dis (f);c
countNode(f );