Advertisement
sildren12

4.4

Nov 30th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.60 KB | None | 0 0
  1. program project1;
  2. var
  3.   plik1:textfile;
  4.   linia:string;
  5.  
  6.   function ile(var ln:string):boolean;
  7.   var
  8.     i,in:integer;
  9.   begin
  10.   ilen:=0;
  11.   for i:=1 to length(ln) do
  12.       begin
  13.       if (ln[i]='(') then
  14.       ilen:=ilen+1;
  15.       if (ln[i]=')') then
  16.       ilen:=ilen-1;
  17.       end;
  18.   if ilen=0 then
  19.   result:=TRUE;
  20.   if ilen<0 then
  21.   result:=FALSE;
  22.   if ilen<>0 then
  23.   result:=FALSE;
  24.   end;
  25.  
  26. begin
  27.   Assignfile(plik1, 'F:\pascal\we4.txt');
  28.   Reset(plik1);
  29.   while not EOF(plik1) do
  30.   begin
  31.   readln(plik1,linia);
  32.   writeln(ile(linia));
  33.   end;
  34.   closefile(plik1);
  35.   readln;
  36. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement