Mathc initiation/Fichiers c : c15n


Sommaire


Installer ce fichier dans votre répertoire de travail.

x_hprint.h
utilitaire
 /* ---------------------------------- */
/* save as x_hprint.h                  */
/* ---------------------------------- */
void  p_Px(
double *Px)
{
   int c       = 1;
   int Px_NULL = TRUE;
   int degree  = Px[0]-1;

double coeff   = 0.;

printf("   ");

for (c=1; c<Px[0]; c++)
{      
 coeff = Px[c];

 --degree;

 if(coeff)
 {
  Px_NULL = FALSE;
  if(degree)
  {
   if(degree==1)
     {
           if(coeff ==  1)     printf("+ x  ");
      else if(coeff == -1)     printf("- x  ");
      else                     printf("%+.2f*x  ",coeff);
      }
   else
     {
           if(coeff ==  1)     printf("+ x**%d  ",          degree);
      else if(coeff == -1)     printf("- x**%d  ",          degree);
      else                     printf("%+.2f*x**%d  ",coeff,degree);
      }
  }
  else printf("%+.2f  ",coeff);
 }
}

   if(Px_NULL){printf("   0");}

   printf("\n\n");
}


/* ---------------------------------- */
/* ---------------------------------- */


La fonction imprime un polynôme.