Float Test.c 778 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #define USE_TI89
  2. #define USE_TI92PLUS
  3. #define USE_V200
  4. #define SAVE_SCREEN
  5. #include <stdio.h>
  6. #include <math.h>
  7. #include <string.h>
  8. #include <kbd.h>
  9. void _main(void)
  10. {
  11. float a, b, c, d;
  12. char buffer[200];
  13. clrscr ();
  14. puts ("a=");
  15. a = atof (gets (buffer));
  16. puts ("b=");
  17. b = atof (gets (buffer));
  18. puts ("c=");
  19. c = atof (gets (buffer));
  20. if (is_nan (a) || is_nan (b) || is_nan (c)) return;
  21. d = b * b - 4. * a * c;
  22. if (d >= 0.)
  23. {
  24. float x1, x2;
  25. x1 = (-b + sqrt (d)) / (2. * a);
  26. x2 = (-b - sqrt (d)) / (2. * a);
  27. printf ("\nx1=%f\nx2=%f", x1, x2);
  28. }
  29. else
  30. {
  31. float re, im;
  32. re = -b / (2. * a);
  33. im = fabs (sqrt (-d) / (2. * a));
  34. printf ("\nx1=%f-%f*i\nx2=%f+%f*i", re, im, re, im);
  35. }
  36. ngetchx();
  37. }