summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbiouman <biouman>2001-04-29 23:07:08 +0000
committerbiouman <biouman>2001-04-29 23:07:08 +0000
commit67cc2ba2e81241774373f4667f1bac71234ecf11 (patch)
treed6e0cc3364703ad3b13fd7e4621ce2f22fd5b7b7
parent6a27e9676e432ae176ff00d8fd7336a7a86bf9a2 (diff)
*** empty log message ***
-rw-r--r--lib/polynom.c10
-rw-r--r--src/Polynom.c3
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;