home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / C / CSORT.ZIP / CSORT.C next >
Encoding:
C/C++ Source or Header  |  1995-07-15  |  20.6 KB  |  726 lines

  1. /************************************************************************
  2.  
  3.  Title: csort.c
  4.                                                                       
  5.   A program which demonstrates the action of six sort algorithms using
  6. animated graphics.
  7.                                                                       
  8.  Date:  9/22/88
  9.  
  10.  Author: Mark Weisz   72057,1566
  11.  
  12.  Compiler: Turbo C 1.5
  13.  
  14.            This program must be run from a project which includes
  15.            graphics.lib. It issumes that the CGA and Hercules
  16.            drivers are in graphics.lib.
  17.  
  18.  Notes:
  19.    Modeled after the program "SEESORT.BAS" written by John P. Grillo
  20.    and J.D. Robertson. Published in "More Color Computer Applications"
  21.    Wiley Press, 1984.
  22.  
  23.    All the algorithms except the Quicksort were adapted from the
  24.    original BASIC code in SEESORT.
  25.  
  26.    The Quicksort is taken from Ray Duncan's "Power Programming" column
  27.    in PC Magazine, September 13, 1988, p. 343. That algorithm in turn
  28.    was adapted from "Algorithms 2nd Edition" by Robert Sedgewick,
  29.    Addison-Wesley, 1988.
  30.  
  31.    The gprintf and Initialize functions were lifted from BGIDEMO.C
  32.    which comes with Turbo C v. 1.5 from Borland International.
  33.  
  34.  
  35. **************************************************************************/
  36.  
  37. #include <conio.h>
  38. #include <ctype.h>
  39. #include <dos.h>
  40. #include <graphics.h>
  41. #include <stdlib.h>
  42. #include <stdarg.h>
  43. #include <stdio.h>
  44. #include <string.h>
  45. #include <math.h>
  46. #include <time.h>
  47.  
  48. #define MAXNUM   200    /* maximum number of array elements to sort */
  49. #define XAXIS    260    /* x coordinate on graphics screen          */
  50. #define YAXIS    15     /* y coordinate on graphics screen          */
  51. #define MAXPICKS 8      /* maximum menu picks given to user         */
  52. #define TIMES    3      /* how many times to perform...             */
  53.  
  54. int xaxis = XAXIS;
  55. int yaxis = YAXIS;
  56.  
  57. enum sort {bubble, delayed, shell, shell_metzner,
  58.            quick, insertion, all, stop};
  59.  
  60. char *sorts[MAXPICKS] =
  61.                  {"Bubble Sort", "Delayed Exchange Sort", "Shell Sort",
  62.                   "Shell-Metzner Sort", "QuickSort", "Insertion Sort",
  63.                    "All", "Exit to Dos"};
  64.  
  65. /*****  function prototypes  *************************/
  66.  
  67. void main( void );
  68. void driver( enum sort atype, int *m, int elements,
  69.              int random, int delay_factor );
  70. enum sort pick_sort( int *elements, int *random, int *delay_factor );
  71. void Initialize( void );
  72. void Setscreen( int *m, int elements, int random );
  73. int  Swap_Pixels( int *m, int i, int j, int delay_factor );
  74. int  gprintf( int *xloc, int *yloc, char *fmt, ... );
  75. void print_menu( char *mysorts[] );
  76. void get_number( int *elements, int *times, char *tstring, int *x, int *y );
  77. void Showdata ( int *m );
  78.  
  79. void Bubble( int *m, int elements, int delay_factor );
  80. void Delayed( int *m, int elements, int delay_factor );
  81. void Shell_Metzner( int *m, int elements, int delay_factor );
  82. void Quicksort( int *m, int left, int right, int delay_factor );
  83. void Insertion( int *m, int elements, int delay_factor );
  84. void Shell( int *m, int elements, int delay_factor );
  85.  
  86.  
  87. /*****  main  ***************************************/
  88. /*                                                  */
  89. /****************************************************/
  90.  
  91. void main( void )
  92. {
  93.  int array[MAXNUM];    /*  the array to be sorted  */
  94.  int elements;         /*  how many elements       */
  95.  int random;           /*  random or worst case    */
  96.  int delay_factor;     /*  delay factor 0-1000     */
  97.  
  98.  enum sort stype = all;
  99.  Initialize();
  100.  while( stype != stop )
  101.    {
  102.     random = 0;
  103.     elements = 0;
  104.     delay_factor = 0;
  105.     stype = pick_sort( &elements, &random, &delay_factor );
  106.     if ( stype != stop )
  107.       {
  108.        driver( stype, array, elements, random, delay_factor );
  109.        /* Showdata( array ); */
  110.        delay( 1350 );
  111.       }
  112.    }
  113.  closegraph();
  114. }
  115.  
  116.  
  117. /*****  pick_sort  *******************************************************
  118.  
  119.   Displays a simple menu and prompts the user for four choices.
  120.  
  121.   called by:  main
  122.  
  123.   calls: print_menu
  124.          gprintf
  125.          get_number
  126.  
  127.  
  128.   returns  :  the sort desired (could be all sorts or quit)
  129.  
  130.   parameters:
  131.  
  132.     *elements
  133.     *random
  134.     *delay_factor
  135. *************************************************************************/
  136.  
  137. enum sort pick_sort( int *elements, int *random, int *delay_factor )
  138. {
  139.  static char query1[] = "Which Sort (1-8)?";
  140.  static char query2[] = "How Many Elements < 200?";
  141.  static char query3[] = "(R)andom or (W)orst Case?";
  142.  static char query4[] = "Delay Factor (0-1000)?";
  143.  
  144.  static char achar[2] = "x";
  145.  char bchar = 0;
  146.  char nstring[TIMES + 1];  /* string equivalent of elements  */
  147.  int tens = TIMES; /* power of ten we're using       */
  148.  int *tpower;
  149.  int x = 50;
  150.  int y = 30;
  151.  char pick = 0;
  152.  int x2;
  153.  int i;    /* scratch variable */
  154.  tpower = &tens;
  155.  
  156.  cleardevice();
  157.  print_menu( sorts );
  158.  
  159.  /************** pick the sort *************************/
  160.  gprintf( &x, &y, query1 );
  161.  while ( pick <= 48 || pick >= 57 )  /* allow digits 1-8 */
  162.   {
  163.    pick = getch();
  164.   }
  165.  achar[0] = pick;
  166.  x2 = x + 4 + textwidth( query1 );
  167.  outtextxy( x2, y, achar );
  168.  
  169.  if ( pick != 56 )
  170.    {
  171.     y = 100;
  172.  
  173.     /******** get number of elements desired *****/
  174.     gprintf( &x, &y, query2 );
  175.     x2 = x + 4 + textwidth( query2  );
  176.     for ( i = 0; i < TIMES + 1; i++ )
  177.       nstring[i] = 0;        /* used to initialize string to nulls */
  178.  
  179.     get_number( elements, tpower, nstring, &x2, &y );
  180.     if ( *elements == 0 || *elements > MAXNUM ) *elements = MAXNUM;
  181.  
  182.     y += textheight("H" ) + 1;
  183.  
  184.     /****** get random or worst case ***********/
  185.     gprintf( &x, &y, query3 );
  186.     bchar = 0;
  187.     while( bchar != 82 && bchar != 87 )
  188.       {
  189.        bchar = toupper( getch( ) );
  190.        if ( bchar == 13 ) bchar = 82;
  191.       }
  192.     *random = ( bchar ^ 87 ); /* XOR checks for (W)orst */
  193.     achar[0] = bchar;
  194.     x2 = x + 4 + textwidth( query3 );
  195.     outtextxy( x2, y, achar );
  196.  
  197.     y += textheight( "H" ) + 1;
  198.  
  199.     /****** get delay factor  ******************/
  200.     gprintf( &x, &y, query4 );
  201.     x2 = x + 4 + textwidth( query4 );
  202.     *tpower = TIMES;
  203.     for ( i = 0; i < TIMES + 1; i++ )
  204.       nstring[i] = 0;        /* used to initialize string to nulls */
  205.  
  206.     get_number( delay_factor, tpower, nstring, &x2, &y );
  207.  
  208.    }
  209.   switch( pick - 48 )
  210.     {
  211.      case 1:
  212.         return( bubble );
  213.      case 2:
  214.         return( delayed );
  215.      case 3:
  216.         return( shell );
  217.      case 4:
  218.         return( shell_metzner );
  219.      case 5:
  220.         return( quick );
  221.      case 6:
  222.         return( insertion );
  223.      case 7:
  224.         return( all );
  225.      default:
  226.         return( stop );
  227.     }
  228. }
  229.  
  230. /*****  print_menu  *****************************************
  231.  
  232.    prints the selection menu to the graphics
  233.     screen like so:
  234.  
  235.                    1. Bubble Sort
  236.                    2. Delayed Exchange Sort
  237.                    3. Shell Sort
  238.                    4. Shell Metzner Sort
  239.                    5. Quicksort
  240.                    6. Insertion Sort
  241.                    7. All
  242.                    8. Exit to Dos
  243.  
  244.     called by: pick_sort
  245.  
  246. *************************************************************/
  247.  
  248. void print_menu( char *mysorts[] )
  249. {
  250.  int x, y;   /* screen coordinates */
  251.  int i;
  252.  x = 240;
  253.  y = 10;
  254.  
  255.  for ( i = 0; i < MAXPICKS; i++ )
  256.    {
  257.     gprintf( &x, &y, "%d. %s", i+1, mysorts[i] );
  258.     y += textheight ( "H" ) + 1;
  259.    }
  260. }
  261.  
  262. /*****  get_number  ******************************************************
  263.  
  264. A recursive routine that accepts numbers using the getch() function, and
  265. displays them on the graphics screen. Only the characters '0' to '9' and
  266. CR are accepted -- the rest are ignored.
  267.  
  268.     called by: pick_sort, get_number
  269.  
  270.     parameters:
  271.  
  272.     int *a_number   holds the integer and returns it to the
  273.                     calling function
  274.  
  275.     int *times      maximum number of times that get_number
  276.                     will be called. acts as a flag to stop
  277.                     the routine when the user enters the maximum
  278.                     allowed digits or hits Carriage Return (CR).
  279.  
  280.     char *tstring   Returns the string equivalent of *a_number
  281.                     i.e. if *a_number = 123, *tstring = "123".
  282.                     It is initialized to all nulls before the initial
  283.                     pass and its length is used to determine the
  284.                     power of ten needed for each digit that is entered.
  285.  
  286.     int *x, *y      coordinates on the graphics screen to display
  287.                     the digits as they are entered. *x is increased with
  288.                     each call by the width of a character using the
  289.                     textwidth function.
  290.  
  291. *************************************************************************/
  292.  
  293. void get_number( int *a_number, int *times, char *tstring, int *x, int *y )
  294. {
  295. int power;         /* power of 10 to multiply a digit by */
  296. char achar[2];
  297. char bchar = 0;
  298. achar[1] = 0;
  299.  
  300. while ( bchar <= 47 || bchar >= 59 )  /* allow digits 0-9 */
  301.   {
  302.    bchar = getch();
  303.    if ( bchar == 13 )   /* 13 = CR; if the user hits ENTER  */
  304.      {
  305.       bchar = 48;
  306.       *times = 0;
  307.       break;
  308.      }
  309.   }
  310.  
  311.  if ( *times )
  312.    {
  313.     achar[0] = bchar;
  314.  
  315.     outtextxy( *x, *y, achar );
  316.     *x = *x + textwidth( achar );
  317.     tstring[TIMES - ( (*times)--)] = achar[0];
  318.     if ( *times )
  319.     get_number( a_number, times, tstring, x, y );
  320.    }
  321.  
  322.     power = (int)( pow10(( strlen( tstring ) - ((*times) + 1))));
  323.     bchar = tstring[*times];
  324.     *a_number += ( power  * ( bchar - 48 ));
  325.     (*times )++;
  326. }
  327.  
  328.  
  329. /*****  driver  **********************************************************
  330.  
  331.    driver runs the sorts using parameters sent to it.
  332.  
  333.    It gets a sort type, the address of the array to sort, the number of
  334. elements, the random/worst case status and the delay factor and sets them
  335. in motion.
  336.  
  337.     called by: main
  338.  
  339.     calls: Setscreen, gprintf, all the sort functions
  340.  
  341.     parameters:
  342.  
  343.     enum sort atype    the desired sort
  344.  
  345.     int *array         the address of the array to sort
  346.  
  347.     int elements       how many elements
  348.  
  349.     int random         random = 1  worst case = 0
  350.  
  351.     int delay_factor   0 = no delay;  1000 = 1 second delay for
  352.                        each switching of elements. The idea is to slow
  353.                        down the animation so the user gets a feel for
  354.                        what's going on. 1000 is _very_ slow.
  355.  
  356. *************************************************************************/
  357.  
  358. void driver( enum sort atype, int *array, int elements,
  359.             int random, int delay_factor )
  360. {
  361.  
  362. switch( atype )
  363.   {
  364.    case all    :
  365.  
  366.    case bubble :
  367.             Setscreen( array, elements, random );
  368.             gprintf( &xaxis, &yaxis, *(sorts + bubble) );
  369.             Bubble( array, elements, delay_factor );
  370.             if ( atype != all ) break; else delay( 1350 );
  371.  
  372.    case delayed:
  373.             Setscreen( array, elements, random );
  374.             gprintf( &xaxis, &yaxis, *(sorts + delayed) );
  375.             Delayed( array, elements, delay_factor );
  376.             if ( atype != all ) break; else delay( 1350 );
  377.  
  378.    case shell  :
  379.             Setscreen( array, elements, random );
  380.             gprintf( &xaxis, &yaxis, *(sorts + shell ));
  381.             Shell( array, elements, delay_factor );
  382.             if ( atype != all ) break; else delay( 1350 );
  383.  
  384.    case shell_metzner:
  385.             Setscreen( array, elements, random );
  386.             gprintf( &xaxis, &yaxis, *(sorts + shell_metzner) );
  387.             Shell_Metzner( array, elements, delay_factor );
  388.             if ( atype != all ) break; else delay( 1350 );
  389.  
  390.    case quick  :
  391.             Setscreen( array, elements, random );
  392.             gprintf( &xaxis, &yaxis, *(sorts + quick) );
  393.             Quicksort( array, 0, elements - 1, delay_factor );
  394.             if ( atype != all ) break; else delay( 1350 );
  395.  
  396.    case insertion:
  397.             Setscreen( array, elements, random );
  398.             gprintf( &xaxis, &yaxis, *(sorts + insertion) );
  399.             Insertion( array, elements, delay_factor );
  400.             if ( atype != all ) break; else delay( 1350 );
  401.  
  402.    case stop:
  403.  
  404.    default:;
  405.   }
  406. }
  407.  
  408.  
  409. /*****  initialize  *********************************/
  410. /*                                                  */
  411. /*  Initializes the Borland graphics drivers.       */
  412. /*                                                  */
  413. /****************************************************/
  414.  
  415. void Initialize( void )
  416. {
  417.  int    GraphDriver; /* The Graphics device driver   */
  418.  int    GraphMode;   /* The Graphics mode value      */
  419.  int    ErrorCode;   /* Reports any graphics errors  */
  420.  
  421.  // if( registerbgidriver(  )  < 0 ) exit(1);
  422.  /* if( registerbgidriver( Herc_driver ) < 0 ) exit(2);
  423.  if( registerbgidriver( EGAVGA_driver ) <0 ) exit(3); */
  424.  
  425.  GraphDriver = DETECT;              /* Request auto-detection */
  426.  initgraph( &GraphDriver, &GraphMode, "" );
  427.  ErrorCode = graphresult();   /* Read result of initialization*/
  428.  if( ErrorCode != grOk )      /* Error occured during init  */
  429.    {
  430.     printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) );
  431.     exit( 1 );
  432.    }
  433. /* settextstyle( SMALL_FONT, HORIZ_DIR, 0 ); */
  434. }
  435.  
  436. /*****  gprintf  ************************************/
  437. /*                                                  */
  438. /*  Used like PRINTF except the output is sent to   */
  439. /*  the screen in graphics mode at the specified    */
  440. /*  co-ordinate. From Borland International.        */
  441. /*                                                  */
  442. /*  The return value from gprintf is not used.      */
  443. /*                                                  */
  444. /****************************************************/
  445.  
  446. int gprintf( int *xloc, int *yloc, char *fmt, ... )
  447. {
  448.  va_list  argptr;  /* Argument list pointer          */
  449.  char str[80];     /* Buffer to build string into    */
  450.  int count;        /* Result of vsprintf for return  */
  451.  
  452.  va_start( argptr, fmt );               /* Initialize va_functions      */
  453.  count = vsprintf( str, fmt, argptr );  /* prints string to buffer      */
  454.  outtextxy( *xloc, *yloc, str );        /* Send string in graphics mode */
  455.  va_end( argptr );                      /* Close va_ functions          */
  456.  return( count );                       /* Return the conversion count  */
  457.  
  458. }
  459.  
  460.  
  461. /*****  Setscreen  *******************************************************
  462.  
  463.    Initializes graphics screen for the sort.
  464.  
  465.    called by: driver
  466.  
  467.    parameters:
  468.  
  469.     int *array         the array to sort
  470.  
  471.     int elements       how many elements
  472.  
  473.     int random         random = 1 or worst case = 0
  474.  
  475. *************************************************************************/
  476.  
  477. void Setscreen( int *array, int elements, int random )
  478. {
  479. int j;
  480.  
  481. cleardevice();
  482.  
  483. if ( random )
  484.   {
  485.    randomize();
  486.    for ( j = 0; j < elements; j++ )
  487.      {
  488.       *( array + j) = random( elements );
  489.       putpixel( 3*j, *(array+j), 10);
  490.      }
  491.   }
  492. else /* initialize worst case */
  493.   {
  494.    for ( j = 0; j < elements; j++ )
  495.      {
  496.       *(array + j) = elements - j;
  497.       putpixel( 3*j, *(array+j), 10);
  498.      }
  499.  
  500.    }
  501. }
  502.  
  503. /*****  Showdata  ***********************************/
  504. /*                                                  */
  505. /*  Displays the values in the first 20 elements    */
  506. /*  of the array.                                   */
  507. /*                                                  */
  508. /****************************************************/
  509.  
  510.  
  511. void Showdata( int *array )
  512. {
  513. int i, j, x, y;
  514. j = 0;
  515. i = 20;
  516. x = 570;
  517. y = 0;
  518.  
  519. while ( j < i )
  520.  {
  521.   gprintf( &x, &y, "%2d: %d ", j+1, array[j] );
  522.   y += textheight( "H" ) + 1; /*  Advance to next line   */
  523.   j++;
  524.  }
  525. }
  526.  
  527.  
  528. /*****  Swap_Pixels  ********************************/
  529. /*                                                  */
  530. /*  Swaps the data in two array elements and        */
  531. /*  changes their respective pixels accordingly.    */
  532. /*  The turning off and on of pixels is what gives  */
  533. /*  the illusion of movement.                       */
  534. /*                                                  */
  535. /****************************************************/
  536.  
  537. int Swap_Pixels( int *array, int i, int j, int delay_factor )
  538. {
  539. int h;
  540. h = *(array + i);
  541. putpixel( 3 * i, *(array + i), 0);
  542. putpixel( 3 * j, *(array + i), 10 );
  543. *(array + i) = *(array + j);
  544. putpixel( 3 * j, *( array + j), 0 );
  545. putpixel( 3 * i, *(array + j), 10 );
  546. *(array + j) = h;
  547.  
  548. delay( delay_factor );
  549. return( h );
  550. }
  551.  
  552. /*****  Bubble  *************************************/
  553. /*                                                  */
  554. /****************************************************/
  555.  
  556. void Bubble( int *array, int elements, int delay_factor )
  557. {
  558. int i,j;
  559.  
  560. for ( i = 0; i < elements - 1 ; i++ )
  561.  for ( j = i + 1; j < elements; j++ )
  562.    {
  563.     if ((*(array+i)) > (*(array+j)))
  564.       {
  565.        Swap_Pixels( array, i, j, delay_factor );
  566.       }
  567.    }
  568. }
  569.  
  570. /*****  Delayed  ************************************/
  571. /*                                                  */
  572. /****************************************************/
  573.  
  574. void Delayed( int *array, int elements, int delay_factor )
  575. {
  576. int p, h, k, i, j;
  577.  
  578. for ( p = 0; p < elements-1; p++ )
  579.  {
  580.   h = p;
  581.   for ( k = p + 1; k < elements ; k++ )
  582.     if (*(array+k) < *(array+h))
  583.       h = k;
  584.   if ( p != h )
  585.    {
  586.     i = h;
  587.     j = p;
  588.     Swap_Pixels( array, i, j, delay_factor );
  589.    }
  590.  }
  591. }
  592.  
  593. /*****  Shell  **************************************/
  594. /*                                                  */
  595. /****************************************************/
  596.  
  597. void Shell( int *array, int elements, int delay_factor )
  598. {
  599.  int p, f, i, j, m;
  600.  
  601.  
  602. p = elements;
  603. while ( p > 1)
  604.   {
  605.    p /= 2;
  606.    /* gprintf( &xaxis, &yaxis, "%d", p );
  607.    y++;   */
  608.    m = elements - p;
  609.    do{
  610.      f = 0;
  611.      for ( j = 0; j < m; j++ )
  612.        {
  613.         i = j + p;
  614.         if (*(array + j) > *(array + i))
  615.           {
  616.            Swap_Pixels( array, i, j, delay_factor );
  617.            f = 1;
  618.           }
  619.        }
  620.      } while( f );
  621.   }
  622. }
  623.  
  624. /*****  Shell-Metzner  ******************************/
  625. /*                                                  */
  626. /****************************************************/
  627.  
  628. void Shell_Metzner( int *array, int elements, int delay_factor )
  629. {
  630. int p, k, t, i, j;
  631.  
  632. p = elements;
  633. p /= 2;
  634. while ( p != 0 )
  635.   {
  636.   k = elements - p;
  637.   for ( t = 0; t < k; t++ )
  638.     {
  639.     i = t;
  640.     while ( i >= 0 )
  641.       {
  642.       j = i + p;
  643.       if (*(array+j) < *(array + i))
  644.         {
  645.         Swap_Pixels( array, i, j, delay_factor );
  646.         i = i - p;
  647.         }
  648.       else
  649.         break;
  650.       }
  651.     }
  652.   p /= 2;
  653.   }
  654. }
  655.  
  656. /*****  Quicksort  **********************************/
  657. /*                                                  */
  658. /****************************************************/
  659.  
  660. void Quicksort( int *array, int left, int right, int delay_factor )
  661. {
  662.  int i, j, t;
  663.  
  664.  if ( right > left )
  665.  {
  666.   i = left - 1; j = right;
  667.   do {
  668.       do i++;
  669.         while ( array[i] < array[right] );
  670.       do j--;
  671.         while ( array[j] > array[right] && j > 0 );
  672.       t = Swap_Pixels( array, i, j, delay_factor );
  673.      } while ( j > i );
  674.  
  675.       putpixel( 3*j, *(array + j), 0);
  676.       array[j] =array[i];
  677.       putpixel( 3*j, *(array + j), 10 );
  678.       putpixel( 3*i, *(array + i), 0 );
  679.       /* putpixel( 3*right, *(array + right), 0); <-- putting this stmt
  680.         here causes duplicate pixels...         */
  681.       array[i] =array[right];
  682.       putpixel( 3*i, *(array + i), 10 );
  683.       /* on the other hand, this one works... why? maybe if
  684.        array[i] ==array[right] there's a problem...   */
  685.       putpixel( 3*right, *(array + right), 0 );
  686.       array[right] = t;
  687.       putpixel( 3*right, *(array + right), 10 );
  688.  
  689.       Quicksort( array, left, i - 1, delay_factor );
  690.       Quicksort( array, i + 1, right, delay_factor );
  691.  
  692.   }
  693. }
  694.  
  695.  
  696. /*****  Insertion  **********************************/
  697. /*                                                  */
  698. /****************************************************/
  699.  
  700. void Insertion( int *array, int elements, int delay_factor )
  701. {
  702.  int p, j, t;
  703.  
  704.  
  705.  for ( p = 0; p < elements - 1; p++ )
  706.    {
  707.     t = *(array + p + 1);
  708.     for ( j = p; j >= 0; j-- )
  709.       {
  710.        if ( t <= *(array + j) )
  711.          {
  712.           *(array + j + 1) = *(array + j);
  713.           putpixel( 3*(j + 1), *(array + j + 1), 10 );
  714.           putpixel( 3*j, *(array + j + 1), 0 );
  715.           delay( delay_factor );
  716.          }
  717.        else
  718.          break;
  719.       }
  720.     *(array + j + 1) = t;
  721.     putpixel( 3*(p + 1), t, 0 );
  722.     putpixel( 3*(j + 1), t, 10 );
  723.    }
  724. }
  725.  
  726. /*****  end code for csort.c  ********************************************/