View Single Post
Old 13-03-2010, 20:13   #1
gabmac2
Senior Member
 
Iscritto dal: Jun 2009
Messaggi: 5524
[C] - Liste - ricorsione di coda

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!

Ultima modifica di gabmac2 : 13-03-2010 alle 22:03.
gabmac2 č offline   Rispondi citando il messaggio o parte di esso