Program bai1;
Uses Crt;
Var a:array[1..20] of string;
xau:string;
i,j,n,g,sd : integer;
Begin
Clrscr;
Writeln(' Bieu dien so tu nhien trong G-Phan:');
Writeln('-------------------------------');
Write('Nhap so tu nhien N = ');Readln(n);
Write('Nhap he so G: = ');Readln(g);
i := 1;sd:=0; xau := '';
if (g = 16) then
begin
while (n >0 ) do
begin
sd := n mod g;
str(sd,xau);
if (sd<10) then
a[i]:= '0' + xau
else
xau := Chr(sd+55);
a[i]:= xau;
n := n div g;
i:=i+1;
end;
end
else
begin
Repeat
sd := n mod g;
str(sd,xau);
a[i]:= xau;
n := n div g;
i:=i+1;
Until n=0;
end;
Write('So can tim la: ');
For j:=i-1 downto 1 do
Write(a[j]);
Readln;
End.