Created
April 15, 2020 16:58
-
-
Save shreeshkhadka/2f1e624c05fe4dcea8e8a0ad63ae6dca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program palindrome; | |
{$APPTYPE CONSOLE} | |
{$R *.res} | |
uses | |
System.SysUtils; | |
var | |
pal: string; | |
i, j: integer; | |
unflip, flip: array of string; | |
begin | |
writeln('enter a string'); | |
readln(pal); | |
writeln; | |
setlength(unflip, length(pal)); | |
setlength(flip, length(pal)); | |
j := -1; | |
for i := 1 to length(pal) do | |
begin | |
j := j + 1; | |
unflip[i] := pal[i]; | |
flip[i] := pal[length(pal) - j]; | |
end; | |
for i := 1 to length(pal) do | |
write(unflip[i]); | |
writeln; | |
for i := 1 to length(pal) do | |
write(flip[i]); | |
writeln; | |
i := 0; | |
repeat | |
i := i + 1; | |
until (unflip[i] <> flip[i]); | |
writeln(i); | |
writeln(length(pal)); | |
if i = (length(pal) + 1) then | |
begin | |
writeln('yes'); | |
end | |
else | |
writeln('no'); | |
readln; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment