Sort Integers.c 734 B

12345678910111213141516171819202122232425262728
  1. // Sort a list of integer values
  2. #define USE_TI89 // Compile for TI-89
  3. #define USE_TI92PLUS // Compile for TI-92 Plus
  4. #define USE_V200 // Compile for V200
  5. #define MIN_AMS 100 // Compile for AMS 1.00 or higher
  6. #define SAVE_SCREEN // Save/Restore LCD Contents
  7. #include <tigcclib.h> // Include All Header Files
  8. // Comparison Function
  9. CALLBACK short int_comp(const void *a, const void *b)
  10. {
  11. return (*(const short*)a) - (*(const short*)b);
  12. }
  13. // Main Function
  14. void _main(void)
  15. {
  16. short list[10] = {2, 9, 3, 6, 4, 2, 3, 3, 1, 5};
  17. int i;
  18. clrscr ();
  19. qsort (list, 10, sizeof (short), int_comp);
  20. for (i = 0; i < 10; i++)
  21. printf ("%d ", list[i]);
  22. ngetchx ();
  23. }