题目: |
Program cz2010_2;
var a:array[1..30]of char;
s,n,i,x,y,z:longint;c:char;
begin
s:=0;readln(x,y);
while not eoln do begin
read(c);
if c<='9' then s:=s*x+ord(c)-ord('0')
else s:=s*x+ord(c)-ord('A')+10;
end;
readln;write(s,’ ‘); n:=0;
while s>0 do begin
n:=n+1;z:=s mod y;
if z>9 then a[n]:=chr(z-10+ord('A'))
else a[n]:=chr(z+ord('0'));
s:=s div y;
end;
for i:=n downto 1 do write(a[i]);
writeln;
end.
【输入1】:
7 2
126
【输入2】:
16 13
3A2B 输出:69 1000101|14891 6A16
|