Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Palindrome-detection/Pascal/palindrome-detection-1.pas
Normal file
23
Task/Palindrome-detection/Pascal/palindrome-detection-1.pas
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
program Palindro;
|
||||
|
||||
{ RECURSIVE }
|
||||
function is_palindro_r(s : String) : Boolean;
|
||||
begin
|
||||
if length(s) <= 1 then
|
||||
is_palindro_r := true
|
||||
else begin
|
||||
if s[1] = s[length(s)] then
|
||||
is_palindro_r := is_palindro_r(copy(s, 2, length(s)-2))
|
||||
else
|
||||
is_palindro_r := false
|
||||
end
|
||||
end; { is_palindro_r }
|
||||
|
||||
{ NON RECURSIVE; see [[Reversing a string]] for "reverse" }
|
||||
function is_palindro(s : String) : Boolean;
|
||||
begin
|
||||
if s = reverse(s) then
|
||||
is_palindro := true
|
||||
else
|
||||
is_palindro := false
|
||||
end;
|
||||
19
Task/Palindrome-detection/Pascal/palindrome-detection-2.pas
Normal file
19
Task/Palindrome-detection/Pascal/palindrome-detection-2.pas
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
procedure test_r(s : String; r : Boolean);
|
||||
begin
|
||||
write('"', s, '" is ');
|
||||
if ( not r ) then
|
||||
write('not ');
|
||||
writeln('palindrome')
|
||||
end;
|
||||
|
||||
var
|
||||
s1, s2 : String;
|
||||
|
||||
begin
|
||||
s1 := 'ingirumimusnocteetconsumimurigni';
|
||||
s2 := 'in girum imus nocte';
|
||||
test_r(s1, is_palindro_r(s1));
|
||||
test_r(s2, is_palindro_r(s2));
|
||||
test_r(s1, is_palindro(s1));
|
||||
test_r(s2, is_palindro(s2))
|
||||
end.
|
||||
19
Task/Palindrome-detection/Pascal/palindrome-detection-3.pas
Normal file
19
Task/Palindrome-detection/Pascal/palindrome-detection-3.pas
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
program PalindromeDetection;
|
||||
var
|
||||
input, output: string;
|
||||
s: char; i: integer;
|
||||
begin
|
||||
writeln('write down your input:');
|
||||
readln(input);
|
||||
output:='';
|
||||
for i:=1 to length(input) do
|
||||
begin
|
||||
s:=input[i];
|
||||
output:=s+output;
|
||||
end;
|
||||
writeln('');
|
||||
if(input=output)then
|
||||
writeln('input was palindrome')
|
||||
else
|
||||
writeln('input was not palindrome');
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue