Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program strr;
- {$APPTYPE CONSOLE}
- uses
- SysUtils;
- var
- a, b: array [1..3000] of string;
- s: string;
- boo: array [1..3000] of boolean;
- i, len, f: integer;
- function fu(c: char): integer;
- begin
- if (ord(c) > 96) then fu := ord(c) - 97
- else fu := (ord(c) - 65) + 26;
- end;
- function tobin(a: integer): string;
- var
- s: string;
- begin
- while (a <> 0) do
- begin
- s := inttostr(a mod 2) + s;
- a := a div 2;
- end;
- while (length(s) < 5) do s := '0' + s;
- tobin := s;
- end;
- function inv(s: string): string;
- var
- i: integer;
- begin
- for i := 1 to length(s) do
- if (s[i] = '0') then s[i] := '1'
- else s[i] := '0';
- inv := s;
- end;
- procedure no();
- begin
- writeln('Ahmat made a mistake');
- halt(0);
- end;
- begin
- readln(s);
- len := length(s);
- for i := 1 to length(s) do a[i] := tobin(fu(s[i]));
- readln(s);
- if (length(s) <> len) then no;
- f := 0;
- for i := 1 to len do b[i] := tobin(fu(s[i]));
- for i := 1 to len do
- if (a[i] = b[i]) then boo[i] := false
- else if (a[i] = inv(b[i])) then boo[i] := true
- else no;
- i := 1;
- while (i <= len) do
- begin
- if (boo[i]) then
- begin
- while (boo[i]) do inc(i);
- inc(f);
- end;
- inc(i);
- end;
- writeln('Ahmat rights');
- writeln(f);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement