主题:一个莫名其妙的问题?
小弟刚学此语言,很不精通!请各位好心人帮忙,先谢过。
程序很好懂,就是提出三个算式,回答,然后根据系统提示进入下一轮,可是在我运行的时候,却发现答完三个问题后,根本不需要回答系统提示,就直接进入下一轮了,而且题还一样,困扰死我了,望各位好心人帮我试试,告诉我问题究竟出在哪里,小弟给大家作揖了!!!
程序如下:
program E54(input,output);
var
x,y,d,e,f,j,h,i:integer;
seed:real;
bool:boolean;
answer: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
bool:=true;
while bool=true do
begin
seed:=2005;
x:=trunc(rand(seed)*100);
y:=trunc(rand(seed)*100);
writeln(x,'+',y,'=?',' ',x,'-',y,'=?',' ',x,'*',y,'=?');
d:=x+y;
e:=x-y;
f:=x*y;
read(h,i,j);
if d=h
then write('correct')
else write('false,it is',d);
if e=i
then write('correct')
else write('false,it is',e);
if f=j
then writeln('correct')
else writeln('false,it is',f);
seed:=seed+1;
writeln('Will you continue ?(Y/N)');
read(answer);
if answer='y'
then bool:=true
else bool:=false
end
end.
程序很好懂,就是提出三个算式,回答,然后根据系统提示进入下一轮,可是在我运行的时候,却发现答完三个问题后,根本不需要回答系统提示,就直接进入下一轮了,而且题还一样,困扰死我了,望各位好心人帮我试试,告诉我问题究竟出在哪里,小弟给大家作揖了!!!
程序如下:
program E54(input,output);
var
x,y,d,e,f,j,h,i:integer;
seed:real;
bool:boolean;
answer: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
bool:=true;
while bool=true do
begin
seed:=2005;
x:=trunc(rand(seed)*100);
y:=trunc(rand(seed)*100);
writeln(x,'+',y,'=?',' ',x,'-',y,'=?',' ',x,'*',y,'=?');
d:=x+y;
e:=x-y;
f:=x*y;
read(h,i,j);
if d=h
then write('correct')
else write('false,it is',d);
if e=i
then write('correct')
else write('false,it is',e);
if f=j
then writeln('correct')
else writeln('false,it is',f);
seed:=seed+1;
writeln('Will you continue ?(Y/N)');
read(answer);
if answer='y'
then bool:=true
else bool:=false
end
end.