Program IPK
Program ipkuas;
type ipk_mhs = record
ipk : real;
nm : string[30];
end;
var i,n,j : integer;
ipkku: array [1..20] of ipk_mhs;
procedure descending_ipk;
var z: real;
x: string;
begin
for i:=1 to n-1 do
begin
for j:= n downto i+1 do
begin
if ipkku[j].ipk > ipkku[j-1].ipk then
begin
z:= ipkku[j].ipk;
x:= ipkku[j].nm;
ipkku[j].ipk:= ipkku[j-1].ipk;
ipkku[j].nm:= ipkku[j-1].nm;
ipkku[j-1].ipk:=z;
ipkku[j-1].nm:=x;
end
else if ipkku[j].ipk = ipkku[j-1].ipk then
begin
if ipkku[j].nm > ipkku[j-1].nm then
begin
x:= ipkku[j].nm;
ipkku[j].nm:= ipkku[j-1].nm;
ipkku[j-1].nm:=x;
end;
end;
end;
end;
end;
begin
writeln(‘PROGRAM LIHAT IPK DAN DIURUTKAN BERDASARKAN DESCENDING’);
writeln;
write(‘Masukkan berapa IPK yang akan diurutkan (maks 20) : ‘); readln(n);
writeln;
for i:= 1 to n do
begin
write (‘IPK Mahasiswa ke ‘ ,i,’ : ‘); readln(ipkku[i].ipk);
write (‘Nama Mahasiswa ke ‘ ,i,’ : ‘); readln(ipkku[i].nm);
end;
descending_ipk;
writeln;
writeln(‘Data IPK setelah diurutkan : ‘);
for j:=1 to n do
writeln (ipkku[j].ipk:5:2,’ ‘,ipkku[j].nm);
readln;
end.
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar