Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.82 KB | None | 0 0
  1. program szyfr;
  2.  
  3. uses    crt;
  4.  
  5. var
  6.     b:array[1..26] of char;
  7.     cezar:array[1..999] of char;
  8.     licz,licz2,i,ikon,j,pr:integer;
  9.     s:string;
  10.     c,x:char;
  11.  
  12. procedure ramka;
  13.   begin
  14.     writeln(' _____________________________________________________' );
  15.     writeln('|                                                     |');
  16.     writeln('|                                                     |');
  17.     writeln('|                                                     |');
  18.     writeln('|_____________________________________________________|');
  19.     gotoxy(2,6);
  20.   end;
  21.  
  22. begin
  23.     clrscr;
  24.     licz:=0;
  25.     for c:='a' to 'z' do
  26.         begin
  27.         inc(licz);
  28.         b[licz]:=c;
  29.         end;
  30.     writeln;
  31.     write('przesuniecie: ');
  32.     readln(pr);
  33.     if pr>26 then
  34.         repeat
  35.             pr:=pr-26;
  36.         until pr<26;
  37.  
  38.         writeln;
  39.         gotoxy(1,3);
  40. //      writeln('___________________________________________________');
  41.         writeln;
  42.         licz:=1;
  43.         ramka;
  44.         while licz<27 do
  45.             begin
  46.             if (licz+pr)<26 then write(' ',b[licz+pr])
  47.             else if (licz+pr)>26 then write(' ',b[licz+pr-26])
  48.                 else write(' z');
  49.                 inc(licz);
  50.             end;
  51.         writeln;
  52.         gotoxy(2,7);
  53.         for i:=1 to 26 do
  54.             begin
  55.                 write(' ',b[i]);
  56.             end;
  57.             writeln;
  58. //      writeln('___________________________________________________');
  59.         writeln;
  60.     gotoxy(1,11);
  61.     write('co zaszyfrowac?: ');
  62.     readln(s);
  63.     writeln;
  64.     ikon:=length(s);
  65.         for i:=1 to ikon do
  66.       begin
  67.         x:=s[i];
  68.         licz2:=0;
  69.         if s[i]=' ' then
  70.           begin
  71.             cezar[i]:=' ';
  72.             writeln;
  73.           end
  74.         else
  75.         begin
  76.           repeat
  77.           inc(licz2);
  78.           until s[i]=b[licz2];
  79.             if (licz2+pr)<26 then cezar[i]:=b[licz2+pr]
  80.             else
  81.                 if(licz2+pr)=26 then cezar[i]:=b[26]
  82.                 else cezar[i]:=b[(licz2+pr)-26];
  83.           writeln(x,'->',cezar[i]);
  84.         end;
  85.       end;
  86.     writeln;
  87.     write(s,'  ->  ');
  88.         for j:=1 to ikon do
  89.         begin
  90.         write(cezar[j]);
  91.         end;
  92.     writeln;
  93.     readkey;
  94. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement