Strict Standards: Declaration of action_plugin_importoldchangelog::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/lib/plugins/importoldchangelog/action.php on line 8 Strict Standards: Declaration of action_plugin_importoldindex::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/lib/plugins/importoldindex/action.php on line 57 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parserutils.php on line 205 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parserutils.php on line 208 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parserutils.php on line 389 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parserutils.php on line 530 Strict Standards: Declaration of cache_instructions::retrieveCache() should be compatible with cache::retrieveCache($clean = true) in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/cache.php on line 291 Deprecated: Function split() is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/auth.php on line 154 Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/auth.php on line 456 Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/auth.php on line 456 Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/auth.php on line 453 Strict Standards: Only variables should be passed by reference in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/doku.php on line 71 palindrom [Programování]
 
Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parser/parser.php on line 66 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parser/lexer.php on line 292 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parser/handler.php on line 22 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parser/handler.php on line 49 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parser/handler.php on line 213 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parser/handler.php on line 241 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parser/handler.php on line 295 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parser/handler.php on line 328 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parser/handler.php on line 575 Deprecated: Assigning the return value of new by reference is deprecated in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/inc/parser/xhtml.php on line 939

Zadání

Zjistěte, zda je zadaný řetězec palindrom (zní stejně, at' se čte normálně či pozpátku). Pro jednoduchost předpokládejte, že obsahuje pouze malá písmena a neobsahuje interpunkční znaménka. Příklady řetězců, kdy by měl program vypsat ANO: „zeman seno dones na mez“, „v elipse spi lev“, „kuna nese nanuk“, „jelenovi pivo nelej“.

Řešení

 
const MAX = 100;
 
function palindrom(retezec: string): boolean;
var
    delkaBezMezer:      integer;
    bezMezer:           array[1..MAX] of char;
    i:                  integer;
    jePalindrom:        boolean;
begin
 
  delkaBezMezer := 0;
 
  for i := 1 to length(retezec) do begin
    if (retezec[i] <> ' ') then begin
      delkaBezMezer := delkaBezMezer + 1;
      bezMezer[delkaBezMezer] := retezec[i];
    end;
  end;
 
  jePalindrom := true;
 
  for i := 1 to (delkaBezMezer div 2) do begin
    if bezMezer[i] <> bezMezer[delkaBezMezer - i + 1] then begin
      jePalindrom := false;
    end;
  end;
 
  palindrom := jePalindrom;
end;
 
var
    veta: string;
begin
  readln(veta);
  if (palindrom(veta)) then begin
    writeln('Je to palindrom.');
  end else begin
    writeln('Neni to palindrom.');
  end;
end.
 
palindrom.txt · Poslední úprava: 2007/12/13 16:33 autor: rimsky
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Strict Standards: Only variables should be passed by reference in /DISK2/WWW/pavel-rimsky.cz/vyuka/wiki/doku.php on line 79