Guest User

Untitled

a guest
Nov 19th, 2019
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. struct elem {
  4. int num;
  5. elem* punt;
  6. };
  7.  
  8. void insCoda (elem* &q, int m) {
  9. elem* p;
  10. elem* p0;
  11. for (q=p0;q!=NULL;q->punt) p=q;
  12. elem* r=new elem;
  13. r->num=m;
  14. r->punt=NULL;
  15. (*p).punt=r;
  16. q=p0;
  17. while (q!=NULL) {
  18. cout<<q->num<<endl;
  19. q=q->punt;
  20. }
  21. }
  22.  
  23. int main () {
  24. elem* p0=new elem;
  25. int a;
  26. p0->num=10;
  27. p0->punt=NULL;
  28. cout<<"Inserisci numero: ";
  29. cin>>a;
  30. insCoda (p0,a);
  31. }
RAW Paste Data