|
|
back to boardwhy compilation error Here is my pascal solution. program DPP_AGAIN; var mass,stack:array[1..10001] of char; kol,ls,i:integer; res,comment,cont:boolean; function arithm:boolean; begin if ((ord(mass[i])>=48) and (ord(mass[i])<=57)) or (mass[i]='/') or (mass[i]='*') or (mass[i]='+') or (mass[i] ='-') or (mass[i]='(') or (mass[i]='=') then arithm:=true else arithm:=false; end; begin { assign(input,'input.txt'); reset(input); assign(output,'output.txt'); rewrite(output);} fillchar(mass,sizeof(mass),#0); fillchar(stack,sizeof(stack),#0); kol:=0; ls:=0; res:=true; while not eof do begin while not eoln do begin inc(kol); read(mass[kol]); end; readln; end; for i:=1 to kol do begin if mass[i]='(' then begin {if begin of comment} if mass[i+1]='*' then begin i:=i+2; while (not ((mass[i]='*') and (mass[i+1]=')'))) and (i<=kol) do inc(i); if i>=kol+1 then res:=false else inc(i); end else {if begin of arithmetic expression} begin comment:=false; inc(i); stack[1]:='('; ls:=1; cont:=true; while cont do begin if (mass[i]='(') and (mass[i+1]='*') then begin comment:=true; inc(i); end; if not comment then begin if mass[i]='(' then begin inc(ls); stack[ls]:='('; end; if (mass[i]=')') then begin if stack[ls]='(' then dec(ls) else res:=false; end else if not arithm then res:=false; end; if (mass[i]=')') and (mass[i-1]='*') then comment:=false; if (i>=kol) then if (comment) or (ls>0) then res:=false; if (ls=0) or (i>=kol) then cont:=false else inc(i); end; end; end else if mass[i]=')' then res:=false; if not res then i:=kol; end; if res then writeln('YES') else writeln('NO'); end. I have the tests for this problem, and all of them work correct at turbo pascal but i get compilation error here at delphi. any ideas? Re: why compilation error Posted by IU712 8 Nov 2002 02:36 > Here is my pascal solution. > > { assign(input,'input.txt'); > reset(input); > assign(output,'output.txt'); > rewrite(output);} > I have the tests for this problem, and all of them work correct at > turbo pascal but i get compilation error here at delphi. any ideas? Use standard input and output (ReadLn, WriteLn). For you information: in Delphi Assign should be written as AssignFile (Close=>CloseFile). Re: why compilation error Posted by sun yi 20 Dec 2002 07:32 I think the problem may be here: for i:=1 to kol do begin inc(i); end; Do not change the value of i while using "for" |
|
|