Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Written in pascal language to convert decimal numbers into binary and hexadecimal numbers.
Written in pascal language to convert decimal numbers into binary and hexadecimal numbers.
Provide the following function to convert 10 into 2 ~ 16, where cc is a long integer of 10, and the result returned by the function is a string:

Function? convert _ b(cc:longint; B: integer): string;

defined variable

K, I, j: integer;

Bb: Array [1..32]? Yes? char

bbb,s:string;

begin

{The following 10 is converted into b, and b does not exceed 16}

k:= 1;

repeat

j:=cc? mod? b;

Case? j? about

0..9:bb[k]:= chr(j+ord(' 0 ');

10:bb[k]:= ' A ';

1 1:bb[k]:= ' B ';

12:bb[k]:= ' C ';

13:bb[k]:= ' D ';

14:bb[k]:= ' E ';

15:bb[k]:= ' F ';

End;

Cc: = cc? div? b;

What if? cc & gt0? then what Inc(k);

Until? cc = 0;

BBB:=“”;

For what? Me: =k? Tonto? 1? Do what? BBB:= bb b+ bb[I];

str(b:0,s);

BBB:= '('+bb b+ ')'+s;

convert _ b:= BBB;

End;