Palindrome/fr: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 2 | - | ||
| 3 | - | ||
| 4 | - | ||
| 1 | + |  | |
| 5 | 2 | ||
| 6 | 3 | # Palindrome | |
| 7 | 4 | ||
| 8 | 5 | 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. | |
| 9 | 6 | ||
| 10 | 7 | # Exemples | |
| 11 | 8 | ||
| 12 | 9 | ## Anglais | |
| 13 | 10 | ||
| 14 | 11 | - racecar | |
| 15 | 12 | - A man, a plan, a canal: Panama | |
| 16 | 13 | - Madam I'm Adam | |
| 17 | 14 | ||
| 18 | 15 | ## Arabe | |
| 19 | 16 | ||
| 20 | 17 | - مودته تدوم لكل هول * وهل كل مودته تدوم | |
| 21 | 18 | ||
| 22 | 19 | ## Arménien | |
| 23 | 20 | ||
| 24 | 21 | - Արա իմ, առած դրամ՝ քաղաքեքաղաք մարդ ծառա մի արա | |
| 25 | 22 | - Սերամա՜հ եթե համարես | |
| 26 | 23 | ||
| 27 | 24 | ## Finnois | |
| 28 | 25 | ||
| 29 | 26 | - saippuakivikauppias | |
| 30 | 27 | - No niin, on aamu. Kehua sinua kai saan, ah, ihana Kristian. Nait Sirkan, ah, ihana asia, kaunis. Au, hekumaa. No niin on. | |
| 31 | 28 | - No, oikotie vei Tokioon. | |
| 32 | 29 | ||
| 33 | 30 | ## Russe | |
| 34 | 31 | ||
| 35 | 32 | - А роза упала на лапу Азора | |
| 36 | 33 | - луну дунул | |
| 37 | 34 | - лак резала зеркал | |
| 38 | 35 | ||
| 39 | 36 | ## Français | |
| 40 | 37 | ||
| 41 | 38 | - La mariée ira ma | |
| 42 | 39 | - Noël a trop par rapport à Léon | |
| 43 | 40 | - Ésope reste ici et se repose | |
| 44 | 41 | - a nana snob porte de trop bons ananas | |
| 45 | 42 | - Éric notre valet alla te laver ton ciré (vous pouvez remplacer Eric par Luc;-) | |
| 46 | 43 | ||
| 47 | 44 | # Fonction IsPalindome | |
| 48 | 45 | ||
| 49 | 46 | Cette fonction convient à la fois pour les encodages ASCII et UTF-8. | |
| 50 | 47 | ||
| 51 | 48 | ``` pascal | |
| 52 | 49 | function IsPalindome(const a_text: string): boolean; | |
| 53 | 50 | var | |
| 54 | 51 | i, j :longint; | |
| 55 | 52 | s1, s2, s3 :string; | |
| 56 | 53 | begin | |
| 57 | 54 | s1 := UTF8LowerCase( a_text ); | |
| 58 | 55 | j := length( s1 ); | |
| 59 | 56 | i := 1; | |
| 60 | 57 | s2 := ''; | |
| 61 | 58 | s3 := ''; | |
| 62 | 59 | while ( i <= j ) do | |
| 63 | 60 | begin | |
| 64 | 61 | if s1[i] < #$C0 then // ASCII | |
| 65 | 62 | begin | |
| 66 | 63 | if (s1[i] >= #$30) and (s1[i] < #$7B)then | |
| 67 | 64 | begin | |
| 68 | 65 | if (s1[i] > #$60) or (s1[i] < #$3A) then | |
| 69 | 66 | begin | |
| 70 | 67 | s2 := s1[i] + s2; | |
| 71 | 68 | s3 := s3 + s1[i]; | |
| 72 | 69 | end; | |
| 73 | 70 | end; | |
| 74 | 71 | inc( i ); | |
| 75 | 72 | end | |
| 76 | 73 | else | |
| 77 | 74 | begin | |
| 78 | 75 | begin | |
| 79 | 76 | if s1[i] < #$E0 then // two byte | |
| 80 | 77 | begin | |
| 81 | 78 | if ((s1[i] > #$C2) and ( not | |
| 82 | 79 | // Armenian punctuation | |
| 83 | 80 | ((s1[i] = #$D5) and ((s1[i+1] >= #$99) and (s1[i+1] < #$A0))) | |
| 84 | 81 | )) then | |
| 85 | 82 | begin | |
| 86 | 83 | s2 := s1[i]+ s1[i+1] + s2; | |
| 87 | 84 | s3 := s3 + s1[i] + s1[i+1]; | |
| 88 | 85 | end; | |
| 89 | 86 | inc( i ,2); | |
| 90 | 87 | end | |
| 91 | 88 | else | |
| 92 | 89 | begin | |
| 93 | 90 | if s1[i] < #$F0 then // three byte | |
| 94 | 91 | begin | |
| 95 | 92 | if not ( | |
| 96 | 93 | // General punctuation | |
| 97 | 94 | (s1[i] = #$E2) and ((s1[i+1]= #$80) | |
| 98 | 95 | or ((s1[i+1]= #$81) and (s1[i+2]< #$B0))) | |
| 99 | 96 | ) then | |
| 100 | 97 | begin | |
| 101 | 98 | s2 := s1[i]+ s1[i+1] + s1[i+2]+ s2; | |
| 102 | 99 | s3 := s3 + s1[i] + s1[i+1] + s1[i+2]; | |
| 103 | 100 | end; | |
| 104 | 101 | inc( i ,3); | |
| 105 | 102 | end | |
| 106 | 103 | else | |
| 107 | 104 | begin | |
| 108 | 105 | s2 := s1[i]+ s1[i+1] + s1[i+2]+ s1[i+3] + s2; | |
| 109 | 106 | s3 := s3 + s1[i] + s1[i+1] + s1[i+2] + s1[i+3]; | |
| 110 | 107 | inc( i ,4); | |
| 111 | 108 | end | |
| 112 | 109 | end; | |
| 113 | 110 | end; | |
| 114 | 111 | end; | |
| 115 | 112 | end; | |
| 116 | 113 | if s2 <> '' then result := s2=s3 else result := false; | |
| 117 | 114 | end; | |
| 118 | 115 | ``` | |
| 119 | 116 | ||
| 120 | 117 | --- | |
| 121 | 118 | *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](/wiki-contact).* |
