From fb8495ceb3e1ac078d3963b26f7bd5cae94249d3 Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 1 May 2001 17:33:28 +0000 Subject: Pouet --- lib/polynom.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/polynom.c') diff --git a/lib/polynom.c b/lib/polynom.c index dbb4334..859ae48 100644 --- a/lib/polynom.c +++ b/lib/polynom.c @@ -273,28 +273,30 @@ char *ply_affichage(polynome poly) { /* routine d'affichage d'un polynome */ static char buf[BUFSIZ]; char temp[BUFSIZ]; + char * rat; int count = 0; int first = 1; buf[0] = '\0'; if (!poly) { - sprintf(buf, "%s ", rat_to_string(rat_constr(0,1))); - } else { + sprintf(buf, "%s ", rat_to_string(rat_constr(0,1), 1)); + } else { while (poly) { if (poly->degre != 0) { if (smartprint) { + rat = (rat_to_double(poly->coef) == 1) ? (first ? "" : "+ ") : rat_to_double(poly->coef) == -1 ? (first ? "-" : "- ") : rat_to_string(poly->coef, first); switch(poly->degre) { case 1: - sprintf(temp, "%s%s ", rat_to_string(poly->coef, first), mute); + sprintf(temp, "%s%s ", rat, mute); break; case 2: - sprintf(temp, "%s%s² ", rat_to_string(poly->coef, first), mute); + sprintf(temp, "%s%s² ", rat, mute); break; case 3: - sprintf(temp, "%s%s³ ", rat_to_string(poly->coef, first), mute); + sprintf(temp, "%s%s³ ", rat, mute); break; default: - sprintf(temp, "%s%s^%u ", rat_to_string(poly->coef, first), mute, poly->degre); + sprintf(temp, "%s%s^%u ", rat, mute, poly->degre); break; } } else { -- cgit v1.2.3