pascal进制转化程序问题

来源:百度知道 编辑:UC知道 时间:2024/05/29 17:52:04
帮我找找程序问题出在哪?

input
p,q(表示把p进制转化为q进制)
s(具体数字)

output
转化后数字

程序如下:
uses math;
var
a:array[1..100] of longint;
s:string;
n,p,q,m,k,i,j:longint;
begin
readln(p,q);
readln(s);
n:=length(s);
for i:=1 to n do
if ord(s[i])<58
then a[i]:=ord(s[i])-48
else a[i]:=ord(s[i])-55;
m:=0;
for i:=1 to n do
m:=m+a[i]*power(p,n-i);
fillchar(a,sizeof(a),0);
i:=1;
while m>0 do
begin
a[i]:=m mod q;
m:=m div q;
inc(i);
end;
for i:=100 downto 1 do
if a[i]<>0 then break;
for j:=i downto 1 do
if a[j]<10 then write(a[j]) else write(chr(a[j]+55));
end.

运行错误:
(16,7)error:incompatible types:got "extended" expected "longint"
(30)fatal:there were 1 errors compiling module ,stopping
(30)fatal:compilation aborted
lz

const
change:array[0..19]of char=('0','1','2','3','4','5','6','7','8','9',
'A','B','C','D','E','F','G','H','I','J');
unchange:array['A'..'J']of integer=(10,11,12,13,14,15,16,17,18,19);

procedure work;
var str:string;
d,m,n,i:longint;
begin
readln(str);
i:=8; while str[i]=' ' do inc(i);
m:=0;
while str[i]<>' ' do
begin
m:=m*10+ord(str[i])-48;
inc(i);
end;
while str[i]=' ' do inc(i);
n:=0;
while i<=length(str) do
begin
n:=n*10+ord(str[i])-48;
inc(i);
end;