-
Notifications
You must be signed in to change notification settings - Fork 0
/
LL9_removefibnodes.c
154 lines (132 loc) · 2.54 KB
/
LL9_removefibnodes.c
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include <stdio.h>
#include<stdlib.h>
struct node{
int info;
struct node*next;
};
struct node*getnode(){
struct node*p;
p=(struct node*)malloc(sizeof(struct node));
return p;
}
void insbeg(struct node**cstart,int x){
struct node*p;
p=getnode();
p->info=x;
if((*cstart)!=NULL){
p->next=(*cstart)->next;
(*cstart)->next=p;
}
else{
*cstart=p;
(*cstart)->next=p;
}
}
void insend(struct node**cstart,int x){
struct node*p;
p=getnode();
p->info=x;
if((*cstart)!=NULL){
p->next=(*cstart)->next;
(*cstart)->next=p;
*cstart=p;
}
else{
*cstart=p;
(*cstart)->next=p;
}
}
void insafter(struct node**q,int x){
struct node*p;
if(q==NULL){
printf("void insertion");
}
else{
p=getnode();
p->info=x;
p->next=(*q)->next;
(*q)->next=p;
}
}
int delbeg(struct node**cstart){
struct node*p;
p=(*cstart)->next;
(*cstart)->next=p->next;
if((*cstart)->next==(*cstart)){
*cstart=NULL;
}
int x=p->info;
free(p);
return x;
}
int delend(struct node**cstart){
struct node*p,*q;
q=*cstart;
p=(*cstart)->next;
while(p!=*cstart){
p=p->next;
}
p->next=(*cstart)->next;
*cstart=p;
int x=q->info;
free(q);
return x;
}
int delafter(struct node**q){
struct node*p;
p=(*q)->next;
(*q)->next=p->next;
int x=p->info;
free(p);
return x;
}
void traverse(struct node*cstart){
struct node*p;
p=cstart->next;
while(p!=cstart){
printf("%d ",p->info);
p=p->next;
}
printf("%d \n",p->info);
}
int maximum(struct node *cstart)
{
struct node *p;
p=cstart->next;
int max=0;
while(p!=cstart->next)
{
if(p->info > max)
{
max=p->info;
}
p=p->next;
}
if(p->info > max)
{
max=p->info;
}
return max;
}
int removefibnodes(struct node *cstart){
int m = maximum(cstart);
int DAT[m];
for(int i=0 ; i<m ; i++){
DAT
}
}
int main()
{
struct node*cstart;
cstart=NULL;
insbeg(&cstart,10);
insbeg(&cstart,20);
insbeg(&cstart,30);
insbeg(&cstart,40);
insbeg(&cstart,50);
insbeg(&cstart,60);
traverse(cstart);
delbeg(&cstart);
traverse(cstart);
return 0;
}