Advertisement
andhacker

Untitled

Oct 15th, 2023
1,477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.82 KB | None | 0 0
  1. var
  2.   s, ns:string;
  3.   i, num10: integer;
  4.  
  5. function bin2dec(s:string):integer;
  6. var
  7.   nums: String;
  8.   i:integer;
  9. begin
  10.    nums:='01';
  11.    result:=0;
  12.    for i:=1 to length(S) do
  13.     result:=result+(pos(S[i],nums)-1)*round(Exp((length(S)-i)*Ln(2)));
  14. end;
  15.  
  16. begin
  17.   read(s);
  18.   s := LowerCase(s);
  19.   ns := '';
  20.  
  21.   i := 1;
  22.   while (i < length(s) - 1) do // цикл по всей строке
  23.   begin
  24.     if ((i + 2 <= length(s)) and (s[i] = 'o') and (s[i + 1] = 'n') and (s[i + 2] = 'e')) then
  25.     begin
  26.       ns := ns + '1';
  27.       i := i + 3;
  28.     end
  29.     else
  30.     if ((i + 3 <= length(s)) and (s[i] = 'z') and (s[i + 1] = 'e') and (s[i + 2] = 'r') and (s[i + 3] = 'o')) then
  31.     begin
  32.       ns := ns + '0';
  33.       i := i + 4;
  34.     end
  35.     else
  36.       inc(i);
  37.   end;
  38.  
  39.   writeln(IntToStr(bin2dec(ns)));
  40. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement