//*****************************************************************//
//    Mengurutkan data array string menggunakan bubble sort        //
//                        http://wirautama.net                     //
//*****************************************************************//
#include 
#include 
#include 
void main()
{
	clrscr();
   //declare the variable and array
   int n, test;
   char data[10][100];
   char tmp[100];
   n = 10;
   //input data
   for(int i=0; i
 
   {
   	cout<<"Data "<<(i+1)<<" : ";
      cin>>data[i];
   }
   //sort data using bubble sort
   for(int i=0; i
   {
   	for(int j=i+1; j
      {
      	test = strcmp(data[i], data[j]);
         if(test > 0)
         {
         	strcpy(tmp, data[i]);
            strcpy(data[i], data[j]);
            strcpy(data[j], tmp);
         }
      }
   }
   cout<<<"result> 
   for(int i=0; i
 
   {
   	cout<<"Data "<<(i+1)<<" : "<<
   }
   getch();
}
Comments