turbo pascal 编程错误

来源:百度知道 编辑:UC知道 时间:2024/06/19 16:37:38
这个是十进制数转换成R进制数的程序,有错误吗?
Program qqw;
Var
m,n,t,q,w:longint;e,i,r,l:Integer;
s,a:Array[1..35]of Integer;
Begin
ReadLn(n,r);
l:=0;q:=n;w:=n;
m:=Trunc(q);
t:=Fruc(w);
While q>o Do Begin
Inc(l);
a[l]:=q MOD r;
q:=a DIV r;
End;
l:=0;
While w>0 Do Begin
Inc(l);
s[l]:=Tranc(w*r);
w:=Frac(w*r);
End;
Write('(',n,')10=(');
For i:=l Downto 1 Do
If a[i] < 10 Then Write(a[i])
Else Write(chr(a[i]+55));
Write('.');
For i:=l Downto 1 Do
If a[i] < 10 Then Write(a[i])
Else Write(chr(a[i]+55));
WriteLn(')',r);
End.

Program qqw;
Var
m,n,t,q,w:longint;e,i,r,l:Integer;
s,a:Array[1..35]of Integer;
Begin
ReadLn(n,r);
l:=0;q:=n;w:=n;
m:=Trunc(q);
t:=Fruc(w);
While q>o Do Begin (o改成0)
Inc(l);
a[l]:=q MOD r;
q:=a DIV r;
End;
l:=0;
While w>0 Do Begin
Inc(l);
s[l]:=Tranc(w*r);(tranc是不是写错了额,应该是trunc吧,后面的frac也是
w:=Frac(w*r);
End;
Write('(',n,')10=(');
For i:=l Downto 1 Do
If a[i] < 10 Then Write(a[i])
Else Write(chr(a[i]+55));
Write('.');
For i:=l Downto 1 Do
If a[i] < 10 Then Write(a[i])
Else Write(chr(a[i]+55));
WriteLn(')',r);
End.

建议用FO7.0编译,数据范围会更大,用longint

1 t:=Fruc(w); 什么东东!
2 O 没定义
3 Tranc(w*r); 什么东东!
4 用longint
5 程序无法结束