mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-07 20:46:16 +08:00
@@ -32,17 +32,33 @@ void insert(int x)
|
||||
}
|
||||
}
|
||||
|
||||
void remove(int x)
|
||||
{
|
||||
node *t=start;
|
||||
node *p;
|
||||
while(t->val!=x)
|
||||
{
|
||||
p=t;
|
||||
t=t->next;
|
||||
void remove(int x){
|
||||
|
||||
if( start == NULL ){
|
||||
cout<<"\nLinked List is empty\n";
|
||||
return ;
|
||||
}
|
||||
p->next=t->next;
|
||||
delete t;
|
||||
else if( start->val == x ){
|
||||
node *temp = start;
|
||||
start = start->next;
|
||||
delete temp;
|
||||
return ;
|
||||
}
|
||||
|
||||
node *temp = start, *parent = start;
|
||||
|
||||
while( temp != NULL && temp->val != x ){
|
||||
parent = temp;
|
||||
temp = temp->next;
|
||||
}
|
||||
|
||||
if( temp == NULL ){
|
||||
cout <<endl <<x <<" not found in list\n";
|
||||
return ;
|
||||
}
|
||||
|
||||
parent->next = temp->next;
|
||||
delete temp;
|
||||
}
|
||||
|
||||
void search(int x)
|
||||
|
||||
Reference in New Issue
Block a user