Data Structure Practice 5th Meeting

In 5 th meeting We studied about pointer . Here is My program :

1.  Reverse word by using pointer :
2. Sorting data by Pointer
3. Change Upper Case into Lower Case by Pointer
4. Counting FPB(faktor persekutuan terbesar)

1. Reverse word by using pointer :


program balikkata_dengan_pointer;
uses wincrt;
var
kata,balik:^string;
x,a,b:byte;
begin
new(kata);
new(balik);
balik^:='';
write('masukkan kata = ');read(kata^);
x:=length(kata^);
 for a:=x downto 1 do
 begin
 balik^:=balik^+kata^[a];
 end;
writeln('kata awal       = ',kata^);
writeln('setelah dibalik = ',balik^);
dispose(kata);
dispose(balik);
end.

2.  Sorting data by Pointer


program sort_bypointer;
uses wincrt;
const max=10;

type data=^simpul;
simpul=record
bil:byte;
next:data;
end;

var
awal,akhir,baru,help:data;
lok,a,b,c,d,e:byte;
begin
help:=nil;
 for a:=1 to max do
 begin
 new(baru);
 write('index [',a,'] = ');read(baru^.bil);
 baru^.next:=help;
 help:=baru;
 end;

{bubble sort process}
 if help<>nil then
 begin
 awal:=help;
 while awal^.next<>nil do
 begin
 akhir:=awal^.next;
 while akhir<>nil do
 begin
 if awal^.bil>akhir^.bil then
 begin
 lok:=awal^.bil;
 awal^.bil:=akhir^.bil;
 akhir^.bil:=lok;
 end;
 akhir:=akhir^.next;
 end;
 awal:=awal^.next;
 end;
 end;

 while help<>nil do
 begin
 writeln('index = ',help^.bil);
 help:=help^.next;
 end;
end.

3.  Change Upper Case into Lower Case by Pointer

4.  Counting FPB(faktor persekutuan terbesar)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: