标签:
递归练习-进制转换
AYYZOJ p1414
1 var 2 m:integer; 3 procedure tran(n:integer); 4 var k:integer; 5 begin 6 k:=n mod 8; 7 n:=n div 8; 8 if n<>0 then tran(n); 9 write(k); 10 end; 11 begin 12 read(m); 13 tran(m); 14 end.
1 program p1414; 2 var 3 n,h:integer; 4 procedure turndata(n,a:integer); 5 var 6 x:array[1..16] of integer; 7 i,j,k,h:integer; 8 begin 9 if n<0 then writeln(‘-‘); 10 j:=abs(n); 11 k:=0; 12 repeat 13 inc(k); 14 i:=j mod a; 15 j:=j div a; 16 x[k]:=i; 17 until j=0; 18 for h:=k downto 1 do 19 if x[h]<10 then write(x[h]) 20 //else write(chr(55+x[h])); 21 end; 22 begin 23 readln(n); 24 turndata(n,8); 25 end.
标签:
原文地址:http://www.cnblogs.com/vacation/p/5177251.html