wip print before solution
This commit is contained in:
@@ -10,7 +10,46 @@ void print_debug(const char *description, ...)
|
||||
// print the formatted description
|
||||
va_list args;
|
||||
va_start(args, description);
|
||||
// ft_vdprintf(STDOUT_FILENO, description, args); // it's not handling floats for the moment
|
||||
vdprintf(STDOUT_FILENO, description, args);
|
||||
// ft_vdprintf(STDERR_FILENO, description, args); // it's not handling floats for the moment
|
||||
vdprintf(STDERR_FILENO, description, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void print_before_solution(double *polynom, int max_exponent)
|
||||
{
|
||||
int i;
|
||||
|
||||
// reduced form
|
||||
ft_putstr("Reduced form: ");
|
||||
i = max_exponent;
|
||||
printf("%g * x^%i ", ft_fabs(polynom[i]), i);
|
||||
fflush(stdout);
|
||||
i--;
|
||||
while (i >= 0)
|
||||
{
|
||||
if (polynom[i] >= 0)
|
||||
{
|
||||
ft_putchar('+');
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_putchar('-');
|
||||
}
|
||||
printf(" %g * x^%i ", ft_fabs(polynom[i]), i);
|
||||
fflush(stdout);
|
||||
i--;
|
||||
}
|
||||
ft_putstr("= 0\n");
|
||||
|
||||
// // check errors
|
||||
// ft_printf(": ");
|
||||
// ft_printf(": ");
|
||||
// ft_printf(": ");
|
||||
|
||||
// degree
|
||||
ft_printf("Polynomial degree: %i\n", max_exponent);
|
||||
if (max_exponent > 2)
|
||||
{
|
||||
stop_errors("The polynomial degree is strictly greater than 2, I can't solve.\n");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user