document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <stdio>
  2. #include <conio>
  3. #include <iostream>
  4.  
  5. main(){
  6.     int i, j, a, k, m;
  7.     char nm[5][20], temp[40];
  8.  
  9.     cout<<"Inputkan 5 Nama\\n";
  10.  
  11.     for (i=1;i<=5;i++)
  12.      { cout<<"Input nama ke-"<<i<<" = ";gets(nm[i]);
  13.        if (i>1)
  14.         { for (j=1;j<=(i-1);j++)
  15.            { a=(strcmp(nm[i], nm[j]));
  16.                if (a<=0)
  17.                 { strcpy (temp, nm[i]);
  18.                   for (k=(i-1);k>=j;k--)
  19.                    { m=(k+1);
  20.                      strcpy (nm[m], nm[k]);
  21.                    }
  22.                   strcpy (nm[j], temp);
  23.                 }
  24.            }
  25.         }
  26.       }
  27.     cout<<"\\nHasil pengurutannya adalah : \\n";
  28.     for (i=1;i<=5;i++)
  29.      { cout<<"\\n"<<nm[i];}
  30. getch();}
');