Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. struct nodo{int info; nodo* next; nodo(int a=0, nodo* b=0){info=a; next=b;}};
  2. struct FIFO{nodo* primo, *fine; FIFO(nodo*a=0, nodo*b=0){primo=a; fine=b;}};
  3. FIFO metti_fondo(FIFO a, nodo*b){
  4. if(!a.primo){
  5. a.primo=b;
  6. a.fine=a.primo;
  7. }else{
  8. a.fine->next=b;
  9. a.fine=a.fine->next;
  10. }
  11. return a;
  12. }
  13. nodo* togli(nodo* C,int y){
  14. if(!C) return 0;
  15. nodo*A=C;
  16. FIFO x;
  17. while(C){
  18. if(C->info==y){
  19. nodo*B=C->next;
  20. delete C;
  21. C=B;
  22. }else{
  23. x=metti_fondo(x,C);
  24. C=C->next;
  25. }
  26. }
  27. return x.primo;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement