Sortir pada PASCAL

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.

setelah di masukkan kodingan tersebut lalu di compile dan di run, lalu masukkan data yg akan di sortir

dan hasilnya seperti dibawah ini

selesai

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s