Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Design an algorithm to determine whether a number is a palindrome
Design an algorithm to determine whether a number is a palindrome

var

s:string;

i:integer;

begin

readln(s); {Record the number}

for i:=1 to length(s) div 2 do (palindromes correspond in pairs, so only half of them are searched)

if s[i] =s[length(s)+1-i] then continue {If it is, let it continue searching}

else begin dec(i); break; end;{If not, change the pointer i points to the front and jumps out of the loop}

if i=length(s) then writeln("yes")

else writeln("no");{Indicates that the search is completed without receiving Resistance, so it is a palindrome}

end.