PROGRAM SORT;
uses wincrt;
var
nama: array[1..50] of string;
NPM: array[1..50] of string;
kelas: array[1..50] of
string;
s,d,n: byte;
temp: string;
T: boolean;
jawab: char;
const garis='--------------------------------';
begin
repeat
T:=false;
clrscr;
write('Masukkan Jumlah
Data:');
readln(n);
for s:= 1 to n do
begin
write('Data
ke-',s:2,':');readln;
write('Nama
: ');readln(nama[s]);
write('NPM : ');readln(NPM[s]);
write('Kelas :
');readln(kelas[s]);
writeln;
end;
for s:= 1 to n-1 do
begin
for d:= s to n do
begin
if (kelas[d] <
kelas[s]) then
begin
temp :=
nama[d];
nama[d] :=
nama[s];
nama[s] :=
temp;
temp :=
NPM[d];
NPM[d] :=
NPM[s];
NPM[s] :=
temp;
temp :=
kelas[d];
kelas[d] :=
kelas[s];
kelas[s] :=
temp;
end;
end;
end;
writeln;
writeln('Data Setelah
diurutkan:');
for s:= 1 to n do
begin
writeln;
writeln('===DATA MAHASISWA===');
writeln(garis);
writeln('NAMA
NPM KELAS');
writeln(garis);
for s:= 1 to n do
begin
writeln(nama[s]:0,NPM[s]:16,kelas[s]:9);
end;
end;
writeln(garis);
writeln;
write('Akan memproses lagi [Y/T]
?');readln(jawab);
until upcase(jawab)='T';
end.
Output.
dan hasilnya seperti dibawah ini
selesai
Tidak ada komentar:
Posting Komentar