dont print 0 coeffs

This commit is contained in:
Krishna Vedala 2020-04-09 00:19:42 -04:00
parent d3d7cce24d
commit da073120d0
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7
1 changed files with 2 additions and 2 deletions

View File

@ -98,9 +98,9 @@ int main(int argc, char **argv)
for (n = 0; n < degree; n++) for (n = 0; n < degree; n++)
{ {
coeffs[n] = strtod(argv[n + 1], NULL); coeffs[n] = strtod(argv[n + 1], NULL);
if (n < degree - 1) if (n < degree - 1 && coeffs[n] != 0)
printf("(%g) x^%d + ", coeffs[n], degree - n - 1); printf("(%g) x^%d + ", coeffs[n], degree - n - 1);
else else if (coeffs[n] != 0)
printf("(%g) x^%d = 0\n", coeffs[n], degree - n - 1); printf("(%g) x^%d = 0\n", coeffs[n], degree - n - 1);
/* initialize root approximations with random values */ /* initialize root approximations with random values */