主题:10进制转n进制
verysmartboy
[专家分:1260] 发布于 2012-03-03 19:25:00
var s,b,i,j:longint;d:longint;
a:array[1..30] of longint;
begin
write('input a number:');readln(s);write('input the number''s jinzhi:');read(b);if s<=999999999 then begin d:=s;
for i:=1 to 30 do a[i]:=88;
for i:=30 downto 1 do
begin
if s<>0 then begin
a[i]:=s mod b;
s:=s div b;end;
end;
write(d,'=(');
for i:=1 to 30 do
if a[i]<>88 then write(a[i]);
write(')',b,'jz');
end else writeln('the number is wrong!');
readln;
end.
只针对10进制转1、2、3、4、5、6、7、8、9、10进制
3 楼
曲终人散 [专家分:0] 发布于 2014-11-23 19:51:59
不是,我讲一句
10进制转n进制有这么麻烦么?
n还<=10……
var n,x:longint;
procedure cheat(n:longint);
begin
if n=0 then exit
else begin
cheat(n div x);
if n mod x>9 then write(chr((n mod x)+55))
else write(n mod x )
end;
end;
begin
writeln('qing shu ru yao zhuan huan de shu:');readln(n);
writeln('yao zhuan huan de jin zhi shi:');readln(x);
cheat(n);
writeln;
end.
可用10进制转换成任何进制