找错误
pascal吧
全部回复
仅看楼主
level 12
procedure push(var top:longint;ch:char);var stack:array[1..250]of char;
begin
inc(top);
stack[top]:=ch;
end;
procedure pop(var top:longint);
begin
if top=0 then
begin
writeln('no');
halt
end
else dec(top);
end;
var i,top:longint;s,stack:array[1..250]of char;ch:char
;begin
i:=1;
ch:=s[i];
top:=0;
while ch<>'?'do
begin
if(ch='(')or(ch=')')then
case ch of
'(':push(top,ch);
')':if stack=''then
begin
writeln('no');
halt;
end;
else pop(top);
end ;
inc(i);
ch:=s[i];
end;
if top=0 then
writeln('yes')
else writeln('no');
end. ╔═[■]═════════ Information ═════════════╗
║ ║
║ Program ║
║ c:\fpc\2.6.0\bin\i386-win32\007.exe ║
║ exited with ║
║ exitcode = 201 ║
║ ║
║ Ok ▄ ║
║ ▀▀▀▀▀▀▀▀▀ ║
╚════════════════════════════════╝
2013年12月01日 08点12分 1
level 12
堆栈溢出了
2013年12月01日 11点12分 2
1