-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathquli.c
More file actions
63 lines (60 loc) · 945 Bytes
/
Copy pathquli.c
File metadata and controls
63 lines (60 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<stdio.h>
#include<malloc.h>
struct node
{
int x;
struct node *next;
};
struct node *start;
struct node *rear;
void insert(struct node **s,struct node **rear,int value)
{
struct node *a=*s;
struct node *temp=(struct node *)malloc(sizeof(struct node));
temp->next=a;
temp->x=value;
if(*s==NULL)
{
*s=temp;
}
*rear=temp;
}
int delete(struct node **s,struct node **rear)
{
struct node *holder=*rear;
struct node *a=*s;
int p=a->x;
struct node *temp1;
while(holder!=a)
{
temp1=holder;
holder=holder->next;
}
temp1->next=a->next;
a=temp1;
return p;
free(holder);
}
void dis(struct node **s,struct node **rear)
{
//struct node *a=*s;
struct node *b=*rear;
while(b!=NULL)
{
printf("the value are %d\n",b->x);
b=b->next;
}
}
int main()
{
start=NULL;
rear=NULL;
insert(&start,&rear,1);
insert(&start,&rear,2);
dis(&start,&rear);
int d=delete(&start,&rear);
//dis(&start,&rear);
printf("the deleted is %d\n",d);
dis(&start,&rear);
return 0;
}