TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: DAVID NOON
from: KURT KUZBA
date: 1998-04-29 00:56:00
subject: bubble/select 2/2

/*   bbl_slct.c   PUBLIC DOMAIN   part 2 of 2  */
void show_array(int *array, int max)
{
   int i;
   for (i = 0; i < max; i++)
      printf("%4d", array[i]);
}
int main(void)
{
     int table[10] = { 70, 21, 49, 7, 63, 42, 14, 56, 35, 28 };
     float elapsed_time;
     int test;
     puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
     printf("\n\n  Unsorted array is     ::");
     show_array(table, 10);
     puts("\n\n\tA demostration selection sort.");
     selectionsort(table, 10);
     printf("\n  Ascending sort array  ::");
     show_array(table, 10);
     selectionsort(table, -10);
     printf("\n\n  Descending sort array ::");
     show_array(table, 10);
     elapsed_time = (float)clock();
     for(test = 0; test < 10000; test++)
     {
        selectionsort(table, 10);
        selectionsort(table, -10);
     }
     elapsed_time = ((float)clock() - elapsed_time)
      / (float)CLOCKS_PER_SEC;
     printf("\n\n\t10,000 reversal sorts require %.3f seconds.\n",
      elapsed_time);
     puts("\n\n\tA demostration of bubble sort.");
     bubblesort(table, 10);
     printf("\n  Ascending sort array  ::");
     show_array(table, 10);
     bubblesort(table, -10);
     printf("\n\n  Descending sort array ::");
     show_array(table, 10);
     elapsed_time = (float)clock();
     for(test = 0; test < 10000; test++)
     {
        bubblesort(table, 10);
        bubblesort(table, -10);
     }
     elapsed_time = ((float)clock() - elapsed_time)
      / (float)CLOCKS_PER_SEC;
     printf("\n\n\t10,000 reversal sorts require %.3f seconds.\n",
      elapsed_time);
     puts("\nHit a key to continue...");
     getch();
     return 0;
}
/*   end   bbl_slct.c   PUBLIC DOMAIN   part 2 of 2   */
> ] Nothing is absolute, save Grace, Harmony, and Balance.......
---
---------------
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.