Senin, 29 November 2010

Algoritma Palindrom di pascal

program palindrom;
var
a,b:string;
n,i:integer;
found:boolean;
begin
found:=false;
 readln(a);
 n:=length(a);
 for i:=n downto 1 do begin
    b[n-i+1]:=a[i];
 end;
 while ((i<=n) and (not found)) do begin
 if (a[i]=b[i]) then
    i:=i+1
 else found:=true;
 end;
 if found then write('bukan')
 else write('polindrom');
 readln;
end.

Popular Posts

Pages

Followers

Featured Posts