/****************************************************************************/
/*                                                                          */
/* Sample Program 03 : MAIN03.C                                             */
/*                                                                          */
/* COPYRIGHT:                                                               */
/* ----------                                                               */
/* Copyright (C) International Business Machines Corp., 1991, 1993.         */
/*                                                                          */
/* DISCLAIMER OF WARRANTIES:                                                */
/* -------------------------                                                */
/* The following [enclosed] code is sample code created by IBM              */
/* Corporation.  This sample code is not part of any standard IBM product   */
/* and is provided to you solely for the purpose of assisting you in the    */
/* development of your applications.  The code is provided "AS IS",         */
/* without warranty of any kind.  IBM shall not be liable for any damages   */
/* arising out of your use of the sample code, even if they have been       */
/* advised of the possibility of such damages.                              */
/*                                                                          */
/****************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include "sample03.h"
/* #pragma import(selection,,"SAMPLE03",0)  Will be Supported with the ICC Linker */
int main(void)
{
   size_t i;
   int *unsorted,*sorted;

   unsorted = pArray;
   sorted = malloc(nSize *sizeof(int));
   printf("The unsorted array is :\n");
   list(unsorted, nSize);
   for (i = 0; i < nSize; ++i)
      sorted[i] = unsorted[i];
   bubble(sorted, nSize);
   printf("\nThe array sorted by bubble sort is :\n");
   list(sorted, nSize);
   printf("The number of swaps required was %u\n", nSwaps);
   printf("The number of comparisons required was %u\n", nCompares);
   for (i = 0; i < nSize; ++i)
      sorted[i] = unsorted[i];
   insertion(sorted, nSize);
   printf("\nThe array sorted by insertion sort is :\n");
   list(sorted, nSize);
   printf("The number of swaps required was %u\n", nSwaps);
   printf("The number of comparisons required was %u\n", nCompares);
   for (i = 0; i < nSize; ++i)
      sorted[i] = unsorted[i];
   selection(sorted, nSize);
   printf("\nThe array sorted by selection sort is :\n");
   list(sorted, nSize);
   printf("The number of swaps required was %u\n", nSwaps);
   printf("The number of comparisons required was %u\n", nCompares);
   return 0;
}
