tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
26
Task/Palindrome-detection/XPL0/palindrome-detection.xpl0
Normal file
26
Task/Palindrome-detection/XPL0/palindrome-detection.xpl0
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
include c:\cxpl\codes; \intrinsic 'code' declarations
|
||||
string 0; \use zero-terminated strings
|
||||
|
||||
func StrLen(Str); \Return number of characters in an ASCIIZ string
|
||||
char Str;
|
||||
int I;
|
||||
for I:= 0 to -1>>1-1 do
|
||||
if Str(I) = 0 then return I;
|
||||
|
||||
func Palindrome(S); \Return 'true' if S is a palindrome
|
||||
char S;
|
||||
int L, I;
|
||||
[L:= StrLen(S);
|
||||
for I:= 0 to L/2-1 do
|
||||
if S(I) # S(L-1-I) then return false;
|
||||
return true;
|
||||
]; \Palindrome
|
||||
|
||||
int Word, I;
|
||||
[Word:=
|
||||
["otto", "mary", "ablewasiereisawelba", "ingirumimusnocteetconsumimurigni"];
|
||||
for I:= 0 to 4-1 do
|
||||
[Text(0, if Palindrome(Word(I)) then "yes" else "no");
|
||||
CrLf(0);
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue