这是一个利用随机函数自动生成3个四则预算式,加减和乘,可是在程序运行的过程中,程序忽然中断,Delphi报出这个警告“ProjectCalculateGame.exe raise exception dass EInOutError with message'Invalid numberic input'.Process stopped.Use Step or Run to continue.”这个是什么意思啊?是不是程序哪里出了错?麻烦各位看看啦:
program CalculateGame;{$APPTYPE CONSOLE}uses
SysUtils;
Var
a, b, c, x, y, z, m, n, k,score1,score2,score3,tscore: integer;
seed:real;
anser:char;
Function rand(Var seed:real):real;
Const
a=93.0;
m=8192.0;
c=1.0;
begin
seed:=a*seed+c;
seed:=round((seed/m-trunc(seed/m)*m));
rand:=seed/m
end;
begin //主程序
{ TODO -oUser -cConsole Main : Insert code here }
seed:=0.7823;
writeln('Would you want to paly this calculate game?');
writeln('Yes/NO');
read(anser);
While anser<>'No' Do
begin
{生成6个随机数}
a:=trunc(rand(seed)*100);
b:=trunc(rand(seed)*100);
x:=trunc(rand(seed)*100);
y:=trunc(rand(seed)*100);
m:=trunc(rand(seed)*100);
n:=trunc(rand(seed)*100);
writeln(a, '+',b, '=?');
read(c); //读入加法算式结果
writeln(x, '-',y, '=?');
readln(z); //读入减法算式结果
writeln(m, '*',n, '=?');
readln(k); //读入乘法算式结果
{计算分数}
If c=a+b
Then score1:=30
Else score1:=0;
If z=x-y
Then score2:=30
Else score2:=0;
If k=m*n
Then score3:=40
Else score3:=0;
tscore:=score1+score2+score3;
writeln('Your score is');
writeln(tscore);
read(anser)
end
end.
program CalculateGame;{$APPTYPE CONSOLE}uses
SysUtils;
Var
a, b, c, x, y, z, m, n, k,score1,score2,score3,tscore: integer;
seed:real;
anser:char;
Function rand(Var seed:real):real;
Const
a=93.0;
m=8192.0;
c=1.0;
begin
seed:=a*seed+c;
seed:=round((seed/m-trunc(seed/m)*m));
rand:=seed/m
end;
begin //主程序
{ TODO -oUser -cConsole Main : Insert code here }
seed:=0.7823;
writeln('Would you want to paly this calculate game?');
writeln('Yes/NO');
read(anser);
While anser<>'No' Do
begin
{生成6个随机数}
a:=trunc(rand(seed)*100);
b:=trunc(rand(seed)*100);
x:=trunc(rand(seed)*100);
y:=trunc(rand(seed)*100);
m:=trunc(rand(seed)*100);
n:=trunc(rand(seed)*100);
writeln(a, '+',b, '=?');
read(c); //读入加法算式结果
writeln(x, '-',y, '=?');
readln(z); //读入减法算式结果
writeln(m, '*',n, '=?');
readln(k); //读入乘法算式结果
{计算分数}
If c=a+b
Then score1:=30
Else score1:=0;
If z=x-y
Then score2:=30
Else score2:=0;
If k=m*n
Then score3:=40
Else score3:=0;
tscore:=score1+score2+score3;
writeln('Your score is');
writeln(tscore);
read(anser)
end
end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货