Advertisement
Racknoss

Перевод в систему по основанию 2

May 8th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.45 KB | None | 0 0
  1. //Перевод в 2 систему счисления
  2. function St2(b:smallint):int64;
  3. var x:smallint;
  4. Begin
  5. result:=1;
  6. for x:= 1 to b do
  7.  begin
  8.  Result:=Result*2;
  9.  end;
  10. end;
  11. var
  12. n:int64;
  13. b:boolean;
  14. i:smallint;
  15. fix:Int64;
  16. Begin
  17. b:=false;
  18. Readln(n);
  19. for i:= 60 downto 1 do
  20.  begin
  21.  fix:=St2(i);
  22.  if n>=fix then begin write('1'); n:=n-fix; b:=true; end else if b=true then write('0');
  23.  end;
  24. if n=1 then writeln('1') else writeln('0');
  25. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement