Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. program ex9;
  2. uses crt;
  3. var
  4. m:string; bo:boolean; j,i:integer; a:array[1..100]of string; x:array[1..2] of integer;
  5. y:array[1..2] of integer; cry:string;
  6.  
  7. begin
  8. repeat
  9. write('M: '); readln(m);
  10. bo:= true; j:=1;
  11. repeat
  12. if m[j] in ['A'..'Z',' '] then
  13. j:= j+1
  14. else
  15. bo:= false;
  16. until not(bo) or (j> length(m))
  17. until (length(m) mod 2 = 0) and (bo);
  18.  
  19.  
  20. for j:= 1 to length(m)div 2 do
  21. begin
  22. a[j]:= copy(m,1,2);
  23. delete(m,1,2);
  24. i:= 1;
  25. repeat
  26. if a[j][i] = ' ' then
  27. begin
  28. x[i] := 26;
  29. i:= i +1
  30. end
  31. else
  32. begin
  33. x[i] := (ord(a[j][i])-ord('A'));
  34. i:= i+1;
  35. end;
  36. until i=3;
  37. //writeln(a[j],' ',x[1],' ',x[2]);
  38. y[1] := (11*x[1] + 3*x[2]) mod 27;
  39. y[2] := (7*x[1] + 4*x[2]) mod 27;
  40. //writeln(a[j],' ',y[1],' ',y[2]);
  41. cry:= '';
  42. if y[1]+65=91 then
  43. cry:= cry+' '+chr(y[2]+65)
  44. else if y[2] +65=91 then
  45. cry:= cry+chr(y[1]+65)+' '
  46. else cry:= cry+chr(y[1]+65)+chr(y[2]+65);
  47. write(cry);
  48. end;
  49. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement