#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<iomanip.h>
main()
{
char npm[3][10];
char nama[3][30];
char kelas[3][5];
char ipk[3][5];
int tukar;
char temp[3];
int i;
clrscr();
cout<<"DATA MAHASISWA KELAS 2-C\n";
for (i=0; i<=2; i++)
{
cout<<endl;
cout<<"Inputkan NPM = "; gets (npm[i]);
cout<<"Inputkan Nama = "; gets(nama[i]);
cout<<"Inputkan Kelas = "; gets(kelas[i]);
cout<<"Inputkan IPK = "; cin>>ipk[i];
}
clrscr();
cout<<"\n\n DATA MAHASISWA SEBELUM DIURUTKAN :\n";
cout<<endl;
cout<<"================================================================\n";
cout<<" NPM | Nama | Kelas | IPK |\n";
cout<<"================================================================\n\n";
for (i=0; i<=2; i++)
{
cout<<setw(1)<<npm[i]<<" |"<<setw(16)<<nama[i]<<" |"<<setw(9)
<<kelas[i]<<" |"<<setw(6)<<ipk[i]<<" |"<<endl;
}
cout<<"================================================================\n\n";
tukar=1;
while(tukar==1)
{
tukar=0;
for(i=0; i<=3-1; i++)
{
if(strcmp(ipk[i],ipk[i+1])<0)
{
strcpy(temp,ipk[i]);
strcpy(ipk[i],ipk[i+1]);
strcpy(ipk[i+1],temp);
strcpy(temp,nama[i]);
strcpy(nama[i],nama[i+1]);
strcpy(nama[i+1],temp);
strcpy(temp,kelas[i]);
strcpy(kelas[i],kelas[i+1]);
strcpy(kelas[i+1],temp);
strcpy(temp,npm[i]);
strcpy(npm[i],npm[i+1]);
strcpy(npm[i+1],temp);
tukar=1;
}
}
}
cout<<"\n\n DATA MAHASISWA SETELAH DIURUTKAN :\n";
cout<<endl;
cout<<"================================================================\n";
cout<<" NPM | Nama | Kelas | IPK |\n";
cout<<"================================================================\n\n";
for(i=0; i<=2; i++)
{
cout<<setw(1)<<npm[i]<<" |"<<setw(16)<<nama[i]<<" |"<<setw(9)
<<kelas[i]<<" |"<<setw(6)<<ipk[i]<<" |"<<endl;
}
cout<<"================================================================\n\n";
getch();
}