TUGAS 1 (PROGRAM SORTIR)
Agung Priyadi Nugraha
(30111352)
BOGOR
| 2DBO1 MANAJEMEN INFORMATIKA
program sort_report;
uses crt;
var
npm : array[1..20] of string[8];
kelas : array[1..20] of string[5];
nama : array[1..20] of string[30];
m, a : string;
banyak, i, input, n, z : integer;
begin
clrscr;
write('Isi berapa data yang diperlukan : '); readln(banyak);
writeln;
for i := 1 to banyak do
begin
write('NPM = '); readln(npm[i]);
write('KELAS = '); readln(kelas[i]);
write('NAMA = '); readln(nama[i]);
writeln;
end;
{cetak inputan data mahasiswa}
textcolor(red);
writeln ('------------------DATA MAHASISWA------------------');
writeln ('==================================================');
writeln ('NO. NPM KELAS NAMA ');
WRITELN ('==================================================');
for i := 1 to banyak do
begin
writeln (i:2,npm[i]:11, kelas[i]:10, nama[i]:27);
end;
writeln ('==================================================');
{menyortir data}
for input := 1 to banyak do
begin
m := nama[input];
for n := input to banyak do
begin
if (kelas [n] <= m) then
begin
m := kelas[n];
z := n;
end;
end;
a := npm[input];
npm[input] := npm[z];
npm[z] := a;
a := kelas[input];
kelas[input] := kelas[z];
kelas[z] := a;
a := nama[input];
nama[input] := nama[z];
nama[z] := a;
end;
{mencetak data mahasiswa perkelas}
writeln;
textcolor(green);
writeln ('Data Setelah Disortir');
writeln ('--------------------------------------------------');
writeln ('NO. NPM KELAS NAMA ');
writeln ('--------------------------------------------------');
for i := 1 to banyak do
begin
writeln (i:2, npm[i]:11, kelas[i]:10, nama[i]:27);
end;
writeln ('--------------------------------------------------');
readln;
end.
program sort_report;
uses crt;
var
npm : array[1..20] of string[8];
kelas : array[1..20] of string[5];
nama : array[1..20] of string[30];
m, a : string;
banyak, i, input, n, z : integer;
begin
clrscr;
write('Isi berapa data yang diperlukan : '); readln(banyak);
writeln;
for i := 1 to banyak do
begin
write('NPM = '); readln(npm[i]);
write('KELAS = '); readln(kelas[i]);
write('NAMA = '); readln(nama[i]);
writeln;
end;
{cetak inputan data mahasiswa}
textcolor(red);
writeln ('------------------DATA MAHASISWA------------------');
writeln ('==================================================');
writeln ('NO. NPM KELAS NAMA ');
WRITELN ('==================================================');
for i := 1 to banyak do
begin
writeln (i:2,npm[i]:11, kelas[i]:10, nama[i]:27);
end;
writeln ('==================================================');
{menyortir data}
for input := 1 to banyak do
begin
m := nama[input];
for n := input to banyak do
begin
if (kelas [n] <= m) then
begin
m := kelas[n];
z := n;
end;
end;
a := npm[input];
npm[input] := npm[z];
npm[z] := a;
a := kelas[input];
kelas[input] := kelas[z];
kelas[z] := a;
a := nama[input];
nama[input] := nama[z];
nama[z] := a;
end;
{mencetak data mahasiswa perkelas}
writeln;
textcolor(green);
writeln ('Data Setelah Disortir');
writeln ('--------------------------------------------------');
writeln ('NO. NPM KELAS NAMA ');
writeln ('--------------------------------------------------');
for i := 1 to banyak do
begin
writeln (i:2, npm[i]:11, kelas[i]:10, nama[i]:27);
end;
writeln ('--------------------------------------------------');
readln;
end.
donwload link dibawah untuk 4shared
donwload link dibawah untuk ziddu