program Caesar2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

function Cesar(str:string;posun:integer):string;
var
  i: Integer;
begin
 Result := '';
 for i := 1 to Length(str) do
  begin
   if (str[i] = ' ') then
    begin
     Result := Result + ' ';
     continue;
    end;
   if ((str[i] = #13) or (str[i] = #10)) then
    begin
     Result := Result + str[i];
     continue;
    end;

   Result := Result + chr(ord(str[i])+posun);
   case (ord(Result[i])) of
    65..90:begin
      //velka pismena
    end;
    97..122:begin
      //mala pismena
    end;
   end;

   if (ord(Result[i]) > 122) then Result[i] := chr(ord(Result[i])-26);
   if (ord(Result[i]) < 97) then Result[i] := chr(ord(Result[i])+26);
  end;//for i
end;//function

var text,tmp:string;
    posun:Integer;
begin
  try
    writeln('Posun:?');
    readln(posun);
    writeln('Posun:',posun);
    writeln('Input:?');
    readln(tmp);
    while (tmp <> '') do
     begin
      text := text + tmp + #13#10;
      readln(tmp);
     end;
    writeln('output:');
    writeln(Cesar(text,posun));

    readln;
  except
    on E:Exception do
      Writeln(E.Classname, ': ', E.Message);
  end;
end.//program

