diff options
-rw-r--r-- | lib/polynom.c | 10 | ||||
-rw-r--r-- | src/Polynom.c | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/polynom.c b/lib/polynom.c index dcd3b4f..aea2675 100644 --- a/lib/polynom.c +++ b/lib/polynom.c @@ -268,9 +268,15 @@ char *ply_affichage(polynome poly) while (poly) { if (poly->degre != 0) { - sprintf(temp, "%+f*%s^%u", rat_to_double(poly->coef), mute, poly->degre); + if (poly->coef.denom==1) + sprintf(temp, "%+d*%s^%u ", poly->coef.num, mute, poly->degre); + else + sprintf(temp, "%+d/%d*%s^%u ", poly->coef.num, poly->coef.denom, mute, poly->degre); } else { - sprintf(temp, "%+f", rat_to_double(poly->coef)); + if (poly->coef.denom==1) + sprintf(temp, "%+d ", poly->coef.num); + else + sprintf(temp, "%+d/%d ", poly->coef.num , poly->coef.denom); } strcat(buf, temp); /* FIXME: gerer le depassement de buf si po malloc */ poly=poly->suiv; diff --git a/src/Polynom.c b/src/Polynom.c index 5878e41..433da7b 100644 --- a/src/Polynom.c +++ b/src/Polynom.c @@ -37,6 +37,9 @@ int main(void) //printf("-- affichage:%s\n",ply_affichage((polynome)NomVarToVar("P",variables,&valid))); parse_line("P(2);"); + parse_line("Q=6*x^3+4*x^2+x;"); + parse_line("soja=P*Q+2;"); + parse_line("soja;"); //fprintf(stderr, "soja"); printf("Resultat: %s\n", affichage_level_1()); return 0; |