Avrei questa lista e sul testo mi dice che farla cosė č pių semplice ripetto alla tail ,mi potete dare una motivazione?
Codice:
node *somma(node *l1,node *l2){
node *p;int s=0;
if((l1==NULL) && (l2==NULL)) return NULL;
else if((l1!=NULL) && (l2==NULL)){
return somma(l1->next,l2);}
else if((l1==NULL) && (l2!=NULL)){
return somma(l1,l2->next);}
else if((l1!=NULL) && (l2!=NULL)){
if(l1->data==l2->data){
p=newnode();
p->data=l1->data;
p->next=somma(l1->next,l2->next);
return p;}
if(l1->data<l2->data){
return somma(l1->next,l2);}
if(l1->data>l2->data){
return somma(l1,l2->next);}
}
}
Grazie mille in anticipo!