program kuohao; type a=array[1..100]of char; var x:string; y

program kuohao; type a=array[1..100]of char; var x:string; y,i,s,top:integer; b,t:a; begin top:=0;
program kuohao;
type a=array[1..100]of char;
var x:string; y,i,s,top:integer; b,t:a;
begin
top:=0; i:=1; s:=0;
readln(x);
y:=length(x);
repeat
if x[i]='(' then begin
top:=top+1;
b[top]:=x[i];
end;
if x[i]=')' then begin
s:=s+1;
t[s]:=x[i];
end;
inc(i);
until i>y;
if top>s then writeln('< is more');
if topy;
if top>s then writeln('< is more');
if top
JB640118 1年前 已收到1个回答 举报

世界因爱发光 幼苗

共回答了22个问题采纳率:77.3% 举报

注意 else 的用法,程序读入的是字符串,如果你只是判定'('和')'那么遇到这种情况就不可以 (12353425)那中间的数字12353425你的程序只能读入一个1
然后就去判断下一个反括号,而第二个程序是else 即,读入的字符不是'('就执行下一步
s:=s+1;
t[s]:=x[i];
即else 是包含s[i]=')'和其他非'('字符的情况

1年前

3
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 17 q. 0.068 s. - webmaster@yulucn.com