Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct element
- {
- int num;
- element *next;
- };
- int main(){
- element *beg, *help, *last;
- int n;
- cin>>n;
- beg=new element;
- last=beg;
- for(int i=0; i<n; i++){
- help=new element;
- cin>>help->num;
- last->next=help;
- last=help;
- }
- help=beg->next;
- last->next=0;
- int e;
- cin>>e;
- while(help){
- if(help->num==e && help->next && help->next->num!=e){
- last=help->next;
- help->next=last->next;
- delete last;
- }
- help=help->next;
- }
- help=beg;
- /*help=beg;
- while(help->next){
- if(help->next->num > last->num){
- last->next=help->next;
- help->next=last;
- break;
- }
- help=help->next;
- }
- if(!help->next){
- help->next=last;
- last->next=0;
- }
- help=beg;
- */
- while(help->next){
- cout<<help->next->num<<' ';
- help=help->next;
- }
- /*
- 10
- 5 10 15 20 25 30 35 40 45 50
- 34*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement