uses crt;
type
data= record
nama,
nim: string;
ipk :
real;
end;
var
mhs :
array [1..100] of data;
i, j,
n, temp : integer;
pilih
: char;
procedure
input;
begin
clrscr;
write('Masukkan
jumlah mahasiswa : ');
readln(n);
for i
:= 1 to n do
begin
clrscr;
writeln('Masukkan
Data ke- ', i);
writeln('______________________');
write
('Nama : '); readln(mhs[i].nama);
write
('NIM : '); readln(mhs[i].nim);
write
('IPK : '); readln(mhs[i].ipk);
end;
end;
procedure
tampil;
begin
clrscr;
writeln(' ** Tampilkan Data
Mahasiswa **');
writeln;
writeln;
writeln('|---------------------------------------------|');
writeln('| NIM
| Nama | IPK |');
writeln('|---------------------------------------------|');
for
i:=1 to n do
begin
gotoxy(1,6+i);
writeln('|');
gotoxy(10,6+i);
writeln('|');
gotoxy(40,6+i);
writeln('|');
gotoxy(47,6+i);
writeln('|');
gotoxy(3,6+i);
writeln(mhs[i].nim);
gotoxy(14,6+i);
writeln(mhs[i].nama);
gotoxy(42,6+i);
writeln(mhs[i].ipk:2:2);
end;
writeln('|---------------------------------------------|');
readkey;
end;
procedure
selection;
var
max: integer;
temp:
data;
begin
for
i:=1 to n-1 do
begin
max:=i;
for
j:= i+1 to n do
if
mhs[j].ipk> mhs[max].ipk then
max:=j;
temp:=
mhs[max];
mhs[max]:=
mhs[i];
mhs[i]:=
temp;
end;
tampil;
end;
begin
input;
selection;
Output:
Tidak ada komentar:
Posting Komentar