Проверить имеется ли в заданной строке символов баланс открывающихся и закрывающихся круглых скобок — Pascal(Паскаль)

ar
  s:string;
  i,count:integer;
begin
  readln(s);
  count:=0;
  for i:=1 to length(s) do
  begin
    if (s[i]='(') and (count>=0) then
      inc(count);
    if s[i]=')' then
      dec(count);
  end;
  if count=0 then
    writeln('Успешно')
  else
    writeln('Не успешно')
end.

Leave a Comment

42 + = 47