Free Pascal 第十七行语法哪里有错?
vara,b:longint;want,c:char;beginrepeatread(a,b);beginrepeatread(c);write('theanwseris...
var a,b:longint; want,c:char;
begin
repeat
read(a,b);
begin
repeat
read(c); write('the anwser is ');
until (c='+') or (c='-') or (c='*') or (c='/');
case c of
'+':write(a+b);
'-':write(a-b);
'*':write(a*b);
'/':write(a/b);
end;
write(' write "ok" to quit');
until (want='ok');
end. 展开
begin
repeat
read(a,b);
begin
repeat
read(c); write('the anwser is ');
until (c='+') or (c='-') or (c='*') or (c='/');
case c of
'+':write(a+b);
'-':write(a-b);
'*':write(a*b);
'/':write(a/b);
end;
write(' write "ok" to quit');
until (want='ok');
end. 展开
2个回答
展开全部
程序中有几处错误,删了一行"begin",请注意:
var a,b:longint; want,c:char;
begin
repeat
readln(a,b); {此处有更改,否则的话下一行的c会读到回车}
repeat
read(c); write('the anwser is ');
until (c='+') or (c='-') or (c='*') or (c='/');
case c of
'+':write(a+b);
'-':write(a-b);
'*':write(a*b);
'/':write(a/b);
end;
write(' write "ok" to quit');
until (want='ok'); {这一行没用,永远都不可能实现}
end.
最后三行建议改为:
write(' write "E" to quit');
readln(want);
until want="E";
var a,b:longint; want,c:char;
begin
repeat
readln(a,b); {此处有更改,否则的话下一行的c会读到回车}
repeat
read(c); write('the anwser is ');
until (c='+') or (c='-') or (c='*') or (c='/');
case c of
'+':write(a+b);
'-':write(a-b);
'*':write(a*b);
'/':write(a/b);
end;
write(' write "ok" to quit');
until (want='ok'); {这一行没用,永远都不可能实现}
end.
最后三行建议改为:
write(' write "E" to quit');
readln(want);
until want="E";
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询