Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program ex9;
- uses crt;
- var
- m:string; bo:boolean; j,i:integer; a:array[1..100]of string; x:array[1..2] of integer;
- y:array[1..2] of integer; cry:string;
- begin
- repeat
- write('M: '); readln(m);
- bo:= true; j:=1;
- repeat
- if m[j] in ['A'..'Z',' '] then
- j:= j+1
- else
- bo:= false;
- until not(bo) or (j> length(m))
- until (length(m) mod 2 = 0) and (bo);
- for j:= 1 to length(m)div 2 do
- begin
- a[j]:= copy(m,1,2);
- delete(m,1,2);
- i:= 1;
- repeat
- if a[j][i] = ' ' then
- begin
- x[i] := 26;
- i:= i +1
- end
- else
- begin
- x[i] := (ord(a[j][i])-ord('A'));
- i:= i+1;
- end;
- until i=3;
- //writeln(a[j],' ',x[1],' ',x[2]);
- y[1] := (11*x[1] + 3*x[2]) mod 27;
- y[2] := (7*x[1] + 4*x[2]) mod 27;
- //writeln(a[j],' ',y[1],' ',y[2]);
- cry:= '';
- if y[1]+65=91 then
- cry:= cry+' '+chr(y[2]+65)
- else if y[2] +65=91 then
- cry:= cry+chr(y[1]+65)+' '
- else cry:= cry+chr(y[1]+65)+chr(y[2]+65);
- write(cry);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement