Palindrome/fr
Deutsch · English · Français · Suomi

Palindrome
Un palindrome est un mot, une phrase, un nombre ou une autre séquence de symboles ou d'éléments, dont le sens peut être interprété de la même manière dans les deux sens de lecture.
Exemples
Anglais
- racecar
- A man, a plan, a canal: Panama
- Madam I'm Adam
Arabe
- مودته تدوم لكل هول * وهل كل مودته تدوم
Arménien
- Արա իմ, առած դրամ՝ քաղաքեքաղաք մարդ ծառա մի արա
- Սերամա՜հ եթե համարես
Finnois
- saippuakivikauppias
- No niin, on aamu. Kehua sinua kai saan, ah, ihana Kristian. Nait Sirkan, ah, ihana asia, kaunis. Au, hekumaa. No niin on.
- No, oikotie vei Tokioon.
Russe
- А роза упала на лапу Азора
- луну дунул
- лак резала зеркал
Français
- La mariée ira ma
- Noël a trop par rapport à Léon
- Ésope reste ici et se repose
- a nana snob porte de trop bons ananas
- Éric notre valet alla te laver ton ciré (vous pouvez remplacer Eric par Luc;-)
Fonction IsPalindome
Cette fonction convient à la fois pour les encodages ASCII et UTF-8.
function IsPalindome(const a_text: string): boolean;
var
i, j :longint;
s1, s2, s3 :string;
begin
s1 := UTF8LowerCase( a_text );
j := length( s1 );
i := 1;
s2 := '';
s3 := '';
while ( i <= j ) do
begin
if s1[i] < #$C0 then // ASCII
begin
if (s1[i] >= #$30) and (s1[i] < #$7B)then
begin
if (s1[i] > #$60) or (s1[i] < #$3A) then
begin
s2 := s1[i] + s2;
s3 := s3 + s1[i];
end;
end;
inc( i );
end
else
begin
begin
if s1[i] < #$E0 then // two byte
begin
if ((s1[i] > #$C2) and ( not
// Armenian punctuation
((s1[i] = #$D5) and ((s1[i+1] >= #$99) and (s1[i+1] < #$A0)))
)) then
begin
s2 := s1[i]+ s1[i+1] + s2;
s3 := s3 + s1[i] + s1[i+1];
end;
inc( i ,2);
end
else
begin
if s1[i] < #$F0 then // three byte
begin
if not (
// General punctuation
(s1[i] = #$E2) and ((s1[i+1]= #$80)
or ((s1[i+1]= #$81) and (s1[i+2]< #$B0)))
) then
begin
s2 := s1[i]+ s1[i+1] + s1[i+2]+ s2;
s3 := s3 + s1[i] + s1[i+1] + s1[i+2];
end;
inc( i ,3);
end
else
begin
s2 := s1[i]+ s1[i+1] + s1[i+2]+ s1[i+3] + s2;
s3 := s3 + s1[i] + s1[i+1] + s1[i+2] + s1[i+3];
inc( i ,4);
end
end;
end;
end;
end;
if s2 <> '' then result := s2=s3 else result := false;
end;From the Free Pascal wiki, page "Palindrome/fr", as it stood on 2020-02-23 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.