Nama
: M.HIDAYATURACHMAN
Npm
: 34111200
Kelas
: 2DB04
Program
sorting nama dengan menggunakan pascal
program sorting;
uses crt;
type
mahasiswa = record
nama : string
[15];
npm : string [15];
kelas:
string[15];
end;
var
i,j,n : integer ;
mhs : array [1..15]
of mahasiswa;
siswa : mahasiswa;
const
a=('====================================================');
b=('NPM KELAS NAMA');
c=('====================================================');
procedure input;
begin
for i:= 1 to n do
begin
with mhs[i] do
begin
write(mhs[i].npm:0);
write(mhs[i].kelas:20);
write(mhs[i].nama:24);
writeln;
end;
end;
writeln(a);
end;
begin
clrscr;
write('jumlah
mahasiswa : ');readln(n);
for i :=1 to n do
begin
write('NPM:');readln(mhs[i].npm);
write('KELAS:');readln(mhs[i].kelas);
write('NAMA:');readln(mhs[i].nama);
writeln;
end;
write('data semula');
writeln(' ');
writeln(a);
writeln(b);
writeln(c);
begin
input;
end;
{bubble sort}
for i:= 1 to n-1 do
for j:=i+1 to n
do
begin
if mhs[i].nama
> mhs[j].nama then
begin
siswa:=mhs[i];
mhs[i]:=mhs[j];
mhs[j]:=siswa;
end;
end;
writeln;
write('sorting
berdasarkan nama');
writeln(' ');
writeln(b);
writeln(a);
writeln(c);
begin
input;
end;
writeln;
write('selesai...');readln;
readkey;
end.
ini ascending apa descending
BalasHapus