impressive_i

Перевод в 16-чную из 10-ной

May 18th, 2020
147
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program p;
  2. uses crt;
  3.  
  4. var x : integer;
  5.  
  6.  
  7. function get16by10(x : integer):string;
  8. const Xbit : array[10..15] of char = ('A', 'B', 'C', 'D', 'E', 'F');
  9. var    str : string;
  10. begin
  11.   str := '';
  12.   while(x > 0) do begin
  13.      if(x mod 16 >= 10) then
  14.         str := Xbit[x mod 16] + str
  15.      else
  16.         str := IntToStr(x mod 16) + str;
  17.      x := x div 16;
  18.   end;
  19.   result := str;
  20. end;
  21.  
  22. begin
  23.   write(' x = '); readln(x);
  24.   writeln(' x(16) = ', get16by10(x));
  25.  
  26. end.
RAW Paste Data