Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct elem {
- int num;
- elem* punt;
- };
- void insCoda (elem* &q, int m) {
- elem* p;
- elem* p0;
- for (q=p0;q!=NULL;q->punt) p=q;
- elem* r=new elem;
- r->num=m;
- r->punt=NULL;
- (*p).punt=r;
- q=p0;
- while (q!=NULL) {
- cout<<q->num<<endl;
- q=q->punt;
- }
- }
- int main () {
- elem* p0=new elem;
- int a;
- p0->num=10;
- p0->punt=NULL;
- cout<<"Inserisci numero: ";
- cin>>a;
- insCoda (p0,a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement