mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
Update Linked List.cpp
This commit is contained in:
parent
c071083afe
commit
5db2683566
@ -92,6 +92,20 @@ void show()
|
||||
|
||||
}
|
||||
|
||||
void reverse(){
|
||||
node* first = start;
|
||||
node* second = first->next;
|
||||
while(second != NULL){
|
||||
node* tem = second->next;
|
||||
second->next = first;
|
||||
first = second;
|
||||
second = tem;
|
||||
}
|
||||
|
||||
start->next = NULL;
|
||||
start = first;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int choice, x;
|
||||
@ -101,6 +115,7 @@ int main()
|
||||
cout<<"\n2. Delete";
|
||||
cout<<"\n3. Search";
|
||||
cout<<"\n4. Print";
|
||||
cout<<"\n5. Reverse";
|
||||
cout<<"\n0. Exit";
|
||||
cout<<"\n\nEnter you choice : ";
|
||||
cin>>choice;
|
||||
@ -116,7 +131,10 @@ int main()
|
||||
cin>>x;
|
||||
search(x); break;
|
||||
case 4 : show();
|
||||
cout<<"\n"; break;
|
||||
cout<<"\n"; break;
|
||||
case 5 : cout<<"The reversed list: \n";
|
||||
reverse(); show();
|
||||
cout<<"\n"; break;
|
||||
}
|
||||
}
|
||||
while(choice!=0);
|
||||
|
Loading…
Reference in New Issue
Block a user