home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / sclib31 / examples / shellsrt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-31  |  913 b   |  55 lines

  1. #include <scl1.h>
  2. #include <scl1clor.h>
  3. #include <string.h>
  4.  
  5.      /******************
  6.         ShellSort demo */
  7.  
  8. int compare(void *elem1,void *elem2);
  9.  
  10. typedef struct{
  11.      char line[16];
  12.      }LINE;
  13.  
  14. LINE lines[]=
  15.      {
  16.      "******",
  17.      "************",
  18.      "*****",
  19.      "**************",
  20.      "*",
  21.      "*********",
  22.      "*******",
  23.      "***********",
  24.      "*************",
  25.      "********",
  26.      "****",
  27.      "***************",
  28.      "***",
  29.      "**********",
  30.      "**",
  31.      };
  32.  
  33. #define LINES sizeof(lines) / sizeof(LINE)
  34.  
  35. main()
  36. {
  37. Cls(WHITE_BLACK,CLS_ALL);
  38. ShellSort(lines,LINES,sizeof(LINE),compare);
  39. DrawLines();
  40. }
  41.  
  42. DrawLines()
  43. {
  44. int i;
  45.  
  46. for(i=0;i < LINES;i++)
  47.      WriteScreenLen(WHITE_BLACK,i+4,30,sizeof(LINE),(char *)&lines[i]);
  48. }
  49.  
  50. int compare(void *elem1,void *elem2)
  51. {
  52. DrawLines();
  53. WaitTime(10);
  54. return(strcmp((char *)elem1,(char *)elem2));
  55. }