#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
main()
{
char npm[5][10];
int tukar; // 0=jika tdk terjadi pertukaran, 1=terjadi pertukaran
char temp[5]; //temporary=tempat penyimpanan sementara
int i; // indeks
clrscr();
cout<<"Inputkan Data NPM Secara Acak\n";
for (i=0; i<=4; i++)
{
cout<<"Inputkan NPM = "; cin>>npm[i];
}
cout<<"\n\nData NPM sebelum di-sort :\n";
for (i=0; i<=4; i++)
{
cout<<npm[i]<< endl;
}
tukar=1;
while(tukar==1)
{
tukar=0;
for(i=0; i<=4-1; i++)
{
if(strcmp(npm[i],npm[i+1])<0)
{
strcpy(temp,npm[i]);
strcpy(npm[i],npm[i+1]);
strcpy(npm[i+1],temp);
tukar=1;
}
}
}
cout<<"\n\nData NPM setelah di-sort :\n";
for(i=0; i<=4; i++)
{
cout<<npm[i]<<endl;
}
getch();
}