D
dewy718
Unregistered / Unconfirmed
GUEST, unregistred user!
《PASCAL程序设计》书中的例题,编译通过,
运行却出错:
program calculator(input,output);
var
x,y:real;
oper:char;
begin
read(x,oper);
write(x:8:2,oper);
while oper<>'='do
begin
read;
write(y:8:2);
case oper of
'+':x:=x+y;
'-':x:=x-y;
'*':x:=x*y;
'/':x:=x/y
end;
read(oper);
write(oper)
end;
writeln(x:8:2);
writeln('<enter> to exit');
readln
end.
比如输入:3.5*2+1.3-2.4=<enter>
出错:Error 106:Invalid numeric format.
谁能告诉我是什么原因?
运行却出错:
program calculator(input,output);
var
x,y:real;
oper:char;
begin
read(x,oper);
write(x:8:2,oper);
while oper<>'='do
begin
read;
write(y:8:2);
case oper of
'+':x:=x+y;
'-':x:=x-y;
'*':x:=x*y;
'/':x:=x/y
end;
read(oper);
write(oper)
end;
writeln(x:8:2);
writeln('<enter> to exit');
readln
end.
比如输入:3.5*2+1.3-2.4=<enter>
出错:Error 106:Invalid numeric format.
谁能告诉我是什么原因?