У моего маленького проекта много проблем
#include<iostream><pre> #include<cstdio> #include<cstdlib> /* * Node Declaration */ using namespace std; struct node { int info; struct node *next; struct node *prev; }*start; class double_llist { public: void create_list(int value); void Insrt_atFirst(int value); void Insrt_end(int value); void Insert_Afterx(int value, int position); void Remove_atBeginning(int value); void Remove_end(int value); void Remove_aftervaluex(int value ); void display_allItems(); void search(); double_llist() { start = NULL; } }; int main() { int choice, element, position; double_llist dl; while (1) { cout<<endl<<"----------------------------"<<endl; cout<<endl<<"operations="" on="" doubly="" linked="" list"<<endl; ="" cout<<endl<<"----------------------------"<<endl;="" ="" cout<<"1.create="" node"<<endl; ="" cout<<"2.insert="" the="" item="" at="" beginning"<<endl; ="" cout<<"3.insert="" end"<<endl; ="" cout<<"4.insert="" after="" value="" x"<<endl; ="" cout<<"5.remove="" from="" cout<<"6.remove="" cout<<"7.remove="" cout<<"8.display"<<endl; ="" cout<<"9.search="" for="" an="" x="" item"<<endl; ="" cout<<"10.exit"<<endl; ="" cout<<"enter="" your="" choice="" :="" "; ="" cin="">>choice; switch ( choice ) { case 1: cout<<"Enter the element: "; cin>>element; dl.create_list(element); cout<<endl; break; ="" case="" 2: ="" cout<<"enter="" the="" element:="" "; ="" cin="">>element; dl.Insrt_atFirst(element); cout<<endl; break; ="" ="" case="" 7: ="" if="" (start="=" null) ="" {="" cout<<"list="" empty,nothing="" to="" delete"<<endl;="" } ="" cout<<"enter="" the="" element="" for="" deletion:="" "; ="" cin="">>element; dl.Remove_aftervaluex(element); cout<<endl; break; ="" case="" 8: ="" dl.display_allitems(); ="" cout<<endl; ="" ="" 10: ="" exit(1); ="" default: ="" cout<<"wrong="" choice"<<endl; ="" } ="" return="" 0; } ="" * ="" *="" create="" double="" link="" list ="" void="" double_llist::create_list(int="" value) { ="" struct="" node="" *s,="" *temp; ="" temp="new(struct" node);="" temp-="">info = value; temp->next = NULL; if (start == NULL) { temp->prev = NULL; start = temp; } else { s = start; while (s->next != NULL) s = s->next; s->next = temp; temp->prev = s; } } void double_llist::Insrt_atFirst(int value) { if (start == NULL) { cout<<"First Create the list."<<endl; return; ="" } ="" struct="" node="" *temp; ="" temp="new(struct" node); ="" temp-="">prev = NULL; temp->info = value; temp->next = start; start->prev = temp; start = temp; cout<<"Element Inserted"<<endl; } void double_llist::insrt_end="" (int="" value) { ="" if="" (start="=" null) ="" { ="" cout<<"first="" create="" the="" list."<<endl; ="" return; ="" } ="" struct="" node="" *tmp,="" *q; ="" q="start; " ="" tmp="new(struct" node); ="" tmp-="">info = value; if (q->next == NULL) { q->next = tmp; tmp->next = NULL; tmp->prev = q; } /* * Insertion of element at a particular position */ void double_llist::Insert_Afterx(int value, int pos) { if (start == NULL) { cout<<"First Create the list."<<endl; return; ="" } ="" struct="" node="" *tmp,="" *q; ="" int="" i; ="" q="start; " for="" (i="0;i" <="" pos="" -="" 1;i++) ="" { ="">next; if (q == NULL) { cout<<"There are less than "; cout<<pos<<" elements."<<endl; ="" return; ="" } ="" tmp="new(struct" node); ="" tmp-="">info = value; if (q->next == NULL) { q->next = tmp; tmp->next = NULL; tmp->prev = q; } else { tmp->next = q->next; tmp->next->prev = tmp; q->next = tmp; tmp->prev = q; } cout<<"Element Inserted"<<endl; } void double_llist::remove_atbeginning(int="" value) { ="" struct="" node="" *tmp,="" *q; ="" *first="" element="" deletion*="" ="" if="" (start-="">info == value) { tmp = start; start = start->next; start->prev = NULL; cout<<"Element Deleted"<<endl; free(tmp); ="" return; ="" } ="" void="" double_llist::remove_end(int="" value) ="" struct="" node="" *tmp,="" *q; ="" q="start; " while="" (q-="">next->next != NULL) { /*Element deleted in between*/ if (q->next->info == value) { tmp = q->next; q->next = tmp->next; tmp->next->prev = q; cout<<"Element Deleted"<<endl; free(tmp); ="" return; ="" } ="" q="q-">next; } void Remove_aftervaluex(int value ); struct node *tmp, *q; /*last element deleted*/ if (q->next->info == value) { tmp = q->next; free(tmp); q->next = NULL; cout<<"Element Deleted"<<endl; return; ="" } ="" cout<<"element="" "<<value<<"="" not="" found"<<endl; } void="" double_llist::="" search() ="" {="" struct="" node="" *ptr;="" int="" item,i="0,flag;" ptr="head;" if(ptr="=" null)="" cout<<"\nempty="" list\n";="" }="" else="" cout<<"\nenter="" item="" which="" you="" want="" to="" search?\n";="" cin="">>item; while (ptr!=NULL) { if(ptr->data == item) { cout<<"\nitem found at location %d ",i+1; flag=0; break; } else { flag=1; } i++; ptr = ptr -> next; } if(flag==1) { cout<<"\nItem not found\n"; } } } void double_llist::display_dlist() { struct node *q; if (start == NULL) { cout<<"List empty,nothing to display"<<endl; return; ="" } ="" q="start; " cout<<"the="" doubly="" link="" list="" is="" :"<<endl; ="" while="" (q="" !="NULL) " { ="" cout<<q-="">info<<" <-> "; q = q->next; } cout<<"NULL"<<endl; } }< pre=""> What I have tried: i tried to change the declaration <pre lang="c++">
кроме того, я думаю, что Insrt_end неверен и метод поиска