SORTING BERDASARKAN KELAS :
SORTING BERDASARKAN NAMA
NPM DAN NAMA KELAS
program sorting;
uses crt;
type
datamhs= record
npm: string[15];
nama: string[15];
kelas: string[15];
end;
const
garis1=('===============================================');
garis2=('NPM NAMA KELAS');
garis3=('===============================================');
var
n: integer;
i,j,k : byte;
mhs :array[1..15] of datamhs;
D:datamhs;
procedure data;
begin
for i:= 1 to n do
begin
with mhs[i] do
begin
write(mhs[i].npm:5);
write(mhs[i].nama:19);
write(mhs[i].kelas:22);
writeln;
end;
end;
writeln(garis1);
end;
begin
clrscr;
write('masukkan jumlah data : ');readln(n);
for i := 1 to n do
begin
writeln('data ke -',i);
write('NPM :');readln(mhs[i].npm);
write('NAMA :');readln(mhs[i].nama);
write('KELAS :');readln(mhs[i].kelas);
writeln;
end;
clrscr;
writeln('data sebelum sorting : ');
writeln;
writeln(garis1);
writeln(garis2);
writeln(garis3);
begin
data;
end;
writeln;
writeln('sorting berdasarkan kelas : ');
{bubble sort}
for i:= 1 to n-1 do
for j:=i+1 to n do
begin
if mhs[i].kelas>mhs[j].kelas then
begin
D:=mhs[i];
mhs[i]:=mhs[j];
mhs[j]:=D;
end;
end;
writeln(garis1);
writeln(garis2);
writeln(garis3);
begin
data;
end;
writeln;
write('press any key to continue...');readln;
writeln;
for i:= 1 to n-1 do
for j:=i+1 to n do
begin
if mhs[i].nama>mhs[j].nama then
begin
D:=mhs[i];
mhs[i]:=mhs[j];
mhs[j]:=D;
end;
end;
writeln;
writeln('sorting berdasarkan nama : ');
writeln(garis1);
writeln(garis2);
writeln(garis3);
begin
data;
end;
writeln;
write('selesai...');readln;
end.
-------------------------------------------------------------------------------------------------------------
download : program
uses crt;
type
datamhs= record
npm: string[15];
nama: string[15];
kelas: string[15];
end;
const
garis1=('===============================================');
garis2=('NPM NAMA KELAS');
garis3=('===============================================');
var
n: integer;
i,j,k : byte;
mhs :array[1..15] of datamhs;
D:datamhs;
procedure data;
begin
for i:= 1 to n do
begin
with mhs[i] do
begin
write(mhs[i].npm:5);
write(mhs[i].nama:19);
write(mhs[i].kelas:22);
writeln;
end;
end;
writeln(garis1);
end;
begin
clrscr;
write('masukkan jumlah data : ');readln(n);
for i := 1 to n do
begin
writeln('data ke -',i);
write('NPM :');readln(mhs[i].npm);
write('NAMA :');readln(mhs[i].nama);
write('KELAS :');readln(mhs[i].kelas);
writeln;
end;
clrscr;
writeln('data sebelum sorting : ');
writeln;
writeln(garis1);
writeln(garis2);
writeln(garis3);
begin
data;
end;
writeln;
writeln('sorting berdasarkan kelas : ');
{bubble sort}
for i:= 1 to n-1 do
for j:=i+1 to n do
begin
if mhs[i].kelas>mhs[j].kelas then
begin
D:=mhs[i];
mhs[i]:=mhs[j];
mhs[j]:=D;
end;
end;
writeln(garis1);
writeln(garis2);
writeln(garis3);
begin
data;
end;
writeln;
write('press any key to continue...');readln;
writeln;
for i:= 1 to n-1 do
for j:=i+1 to n do
begin
if mhs[i].nama>mhs[j].nama then
begin
D:=mhs[i];
mhs[i]:=mhs[j];
mhs[j]:=D;
end;
end;
writeln;
writeln('sorting berdasarkan nama : ');
writeln(garis1);
writeln(garis2);
writeln(garis3);
begin
data;
end;
writeln;
write('selesai...');readln;
end.
-------------------------------------------------------------------------------------------------------------
download : program
0 komentar:
Posting Komentar