早教吧 育儿知识 作业答案 考试题库 百科 知识分享

2^p高精度运算,数据测试1-4都可以,5就出错了ConstDateNum=1002^p高精度运算,数据测试1-4都可以,5就出错了ConstDateNum=100;TypeBinary=0..1;Num=0..9;VarDate:Array[1..DateNum]ofNum;i,j,Digit,Power:longint;ans0:Binary;

题目详情
2^p高精度运算,数据测试1-4都可以,5就出错了 Const Date_Num=100
2^p高精度运算,数据测试1-4都可以,5就出错了
Const Date_Num=100;
Type Binary=0..1;
Num=0..9;
Var Date:Array[1..Date_Num] of Num;
i,j,Digit,Power:longint;
ans_0:Binary;
Procedure Count_Digit;
Begin
For i:=Date_Num Downto 1 do
If Date[i]0 Then
Begin
Digit:=i;
Exit;
End;
End;
Procedure Double_Ans;
Begin
For i:=1 to Digit+1 do
If Date[i]*2-10+Ans_0>9 then
Begin
Date[i]:=Date[i]*2+Ans_0-10;
Ans_0:=1;
End
Else
Begin
Date[i]:=Date[i]*2+Ans_0;;
Ans_0:=0;
End;
End;
Begin
Writeln('Input the power you want to calculate(2^p=__.)');
Readln(Power);
Fillchar(Date,sizeof(Date),0);
Date[1]:=1;Digit:=1;
For j:=1 to Power do
Begin
Double_Ans;
Count_Digit;
End;
For i:=Digit Downto 1 do Write(Date[i]);
Readln;
End.
▼优质解答
答案和解析
If Date[i]*2-10+Ans_0>9 then 这个判断条件有问题
要改成
If Date[i]*2+Ans_0>9 then