Advertisement
Guest User

Untitled

a guest
May 20th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.70 KB | None | 0 0
  1. Var
  2.   fl,f,f2:File Of Byte;
  3.   f3,f4: text;
  4.   st,c1:string;
  5.   i,j:Integer;
  6.   b,c:Byte;
  7. Begin
  8. AssignFile(f3,'soobshenie.txt');
  9. Reset(f3);
  10. read(f3,st);
  11.     Begin
  12.       AssignFile(fl,'stihforprog.txt');
  13.       Reset(fl);
  14.       AssignFile(f,'shifrovka.txt');
  15.       ReWrite(f);
  16.       For i:=1 To Length(St) Do
  17.         Begin
  18.           C:=Ord(St[i]);
  19.             For j:=7 downTo 0 Do
  20.               Begin
  21.               while not eof(fl) do begin
  22.                 read(fl,b);
  23.                 write(f,b);
  24.                 end;
  25.                 if c and (1 shl j) <> 0 then begin
  26.                 b:=32;
  27.                 write(f,b);
  28.                 end;
  29.                 writeln(f);
  30.                 if not eof(fl) then begin
  31.                 readln(fl,b);
  32.                 write(f,b);
  33.               End;
  34.         End;
  35. If Not Eof(fl) Then
  36.         While Not Eof(fl) Do
  37.           Begin
  38.           If Eof(fl) Then Break;
  39.             Read(fl,c);
  40.             Write(f,c);
  41.           End;
  42.         CloseFile(fl);
  43.         CloseFile(f);
  44.         CloseFile(f3);
  45.     End;
  46.  
  47.     Begin
  48.       AssignFile(f2,'shifrovka.txt');
  49.       Reset(f2);
  50.     While Not Eof(f2) Do
  51.       Begin
  52.         c:=0;
  53.         For i:=7 downto 0 Do
  54.           Begin  
  55.           Repeat
  56.           If Eof(f2) Then Break;
  57.            Read(f2,b);
  58.             Until eoln;
  59.               If Eof(f2) Then Break;
  60.             If b = 32 Then
  61.               c:=c Or (1 shl i);
  62.               readln(f2);
  63.           End;
  64.           AssignFile(f4,'vivod.txt');
  65.           Rewrite(f4);
  66.           begin
  67.           c1:=chr(c);
  68.           if c>0 then write(f4, c1)
  69.           end;
  70.       End;
  71.       CloseFile(f2);
  72.       CloseFile(f4);
  73.     End;
  74. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement