Search Postgresql Archives

Re: SRF written in C

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




El mié, 02-07-2008 a las 10:39 -0400, Alvaro Herrera escribió:
> Felipe de Jesús Molina Bravo wrote:
> 
> > I suspect that my error is:
> > 
> >         r = obtPadre( &intF->izq, &intF->der );
> 
> You didn't show obtPadre().
> 
ok it is: 

        Racional* obtPadre( Racional *li, Racional *ld){
          Racional *lip;
          Racional *tr = NULL; //ap temporal, para hacer el intercambio
          bool      cont;
          int       opAnt; //operacion anterior
        
        
          lip = (Racional *) palloc(sizeof(Racional));
          tr  = (Racional *) palloc(sizeof(Racional));
        
          cont = true;
          opAnt = 0; 
          while( cont ){
            
            if ( li->num > ld->num ){
                //intercambiamos li <-> ld
                 SWAP_RACIONAL(li, ld );
                 cont = false;
            }
            lip->num = ld->num - li->num;
            lip->den = ld->den - li->den;
            if ( cont ){
                 while( cont ){
                    //recorremos
                    SWAP_RACIONAL(li, ld );
                    li->num = lip->num;
                    li->den = lip->den;
        
                    if ( li->num > ld->num ){ //si hay intercambio ...
        continua en el ciclo
                        SWAP_RACIONAL(li, ld );
                    }else{ //si no hay intercambio
                        cont = false; //salimos del ciclo ....
                    }
                    //... pero antes de salir calculamos
                    lip->num = ld->num - li->num;
                    lip->den = ld->den - li->den;
                 }
               
            }
          }
        
          return ( lip );
        }
        




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux