Berikut ini adalah source codenya :
type
Mahasiswa = record
NIM : integer;
Nama : string[20];
Nilai: integer;
end;
var
TabMhs : array[1..100] of Mahasiswa;
bantuan : Mahasiswa;
a, b, n : integer;
procedure bacadata;
begin
for a := 1 to n do
begin
writeln;
write('NIM Mahasiwa ke-',a,' : '); readln(TabMhs[a].NIM);
write('Nama Mahasiwa ke-',a,' : '); readln(TabMhs[a].Nama);
write('Nilai Mahasiwa ke-',a,' : '); readln(TabMhs[a].Nilai);
end;
end;
procedure urut;
begin
for a := 1 to n-1 do
for b := 1 to n-1 do
if TabMhs[b].Nilai < TabMhs[b+1].Nilai then
begin
bantuan := TabMhs[b];
TabMhs[b]:= TabMhs[b+1];
TabMhs[b+1]:= bantuan;
end;
end;
procedure tampil;
begin
writeln;
writeln('------------------------------------');
writeln('|| NIM || Nama || Nilai ||');
writeln('------------------------------------');
for a := 1 to n do
begin
writeln(TabMhs[a].NIM:6,TabMhs[a].Nama:14,TabMhs[a].Nilai:12);
end;
writeln('------------------------------------');
end;
(* PROGRAM UTAMA *)
begin
Write('Jumlah mahasiswa yang diinginkan : '); Readln(n);
bacadata;
clrscr;
Writeln(' *** DATA MAHASISWA *** ');
Writeln(' ====================== ');
Writeln;
urut;
tampil;
end.
0 komentar:
Posting Komentar