summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/polynom.c14
1 files changed, 8 insertions, 6 deletions
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 {