/*************************************************************************
 * prime2.c:
 *************************************************************************/
#include <string.h>
/* local data declaration */

void SortArray(char array[12][10],int n);
void TestOperator();
void TestOperF(int i);
void CompArr(char* str1, char* str2, int* n);

void SortArray(char array[12][10],int n)
{
	unsigned int offset;
	int inOrder;
	unsigned int i,j;	                    
	
    offset=n;
	do {
		offset = (8 * offset)/11;
		offset = ((offset == 0)? 1: offset);
        inOrder = 1;
        for (i=0, j=offset; i<n-offset; i++, j++){
            CompArr(array[i], array[j], &inOrder);
        }
	} while (!(offset == 1 && inOrder));
	return;
}

void CompArr(char *str1, char *str2, int* inOrder)
{
    char temp[10];

    if (strcmp(str1, str2)>0){
        strcpy(temp,str1);
        strcpy(str1,str2);
        strcpy(str2,temp);
        *inOrder = 0;
   }
}

void TestOperator()
  {
   int          i,nOper,nOper1=0x7fff, nOper2=32768;
   short          sOper,sOper1=234, sOper2=45;
   long           lOper,lOper1=87654321,lOper2=12345678;
   float          fOper,fOper1=3.1415926,fOper2=2.16;

   for(i=0;i<=3;i++)
   {
     switch(i) {
        case 0:nOper=nOper1+nOper2;
               nOper=nOper1-nOper2;
        break;

        case 1:sOper=sOper1+sOper2;
               sOper=sOper1-sOper2;
               sOper=sOper1*sOper2;
               sOper=sOper1/sOper2;
        break;

        case 2:lOper=lOper1+lOper2;
               lOper=lOper1-lOper2;
               lOper=lOper1*lOper2;
               lOper=lOper1/lOper2;
        break;

        case 3:fOper=fOper1+fOper2;
               fOper=fOper1-fOper2;
               fOper=fOper1*fOper2;
               fOper=fOper1/fOper2;
        break;
        default:
        break;
      }
   }
   for(i=4;i<8;i++){
       TestOperF(i);
   }
}
  void TestOperF(int i)
  {

   double         dOper,dOper1=3.4E38  ,dOper2=1.1E8;
   char           cOper,cOper1='a',cOper2='z';
   unsigned int   uiOper,uiOper1=65432, uiOper2=12345;
   unsigned short usOper,usOper1=12345, usOper2=54321;

   switch(i){
        case 4:dOper=dOper1+dOper2;
               dOper=dOper1-dOper2;
               dOper=dOper1*dOper2;
               dOper=dOper1/dOper2;
        break;

        case 5:cOper=cOper1+cOper2;
               cOper=cOper1-cOper2;
               cOper=cOper1*cOper2;
               cOper=cOper1/cOper2;
        break;

        case 6:uiOper=uiOper1+uiOper2;
               uiOper=uiOper1-uiOper2;
               uiOper=uiOper1*uiOper2;
               uiOper=uiOper1/uiOper2;
        break;

        case 7:usOper=usOper1+usOper2;
               usOper=usOper1-usOper2;
               usOper=usOper1*usOper2;
               usOper=usOper1/usOper2;
        break;

       defult:
        break;
             }
   return;
 }
                                  
