Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.39 KB | None | 0 0
  1. program lab22;
  2.  
  3. begin
  4.   readln(s);
  5.   q := 0;
  6.  
  7.   for i := 1 to length(s) do
  8.   begin
  9.     if s[i] = '(' then
  10.       q := q + 1;
  11.     if s[i] = ')' then
  12.     begin
  13.       if q = 0 then
  14.       begin
  15.         writeln('Incorrect');
  16.         readln;
  17.         halt;
  18.       end else q := q - 1;
  19.     end;
  20.   end;
  21.  
  22.   if q = 0 then writeln('Correct')
  23.   else writeln('Incorrect');
  24.   readln;
  25.  
  26. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement