|
|
вернуться в форумtest for AC (*(*) what is your idea about this? WA#10 Give me some tests! I can't find my mistake. See my prog: Const s='=+-*/0123456789)('; VAR k1,k2,i,p,r :longint; ch :char; Procedure KOMEN(var ch:char); begin inc(k2); while (not (eof))and(k2<>0) do begin read(ch); while ch='*' do begin read(ch); while (ch<#27) do read(ch); if ch=')' then begin dec(k2); break end; end; end; end; BEGIN r:=0; while not (eof) do begin if r=0 then read(ch) else r:=0; if ch='(' then begin read(ch); while (ch<#27)and(not (eof)) do read(ch); if ch='*' then begin KOMEN(ch); if eof then break; end else begin inc(k1); if ch=')' then dec(k1); p:=0; if ch='(' then inc(k1); for i:=1 to 17 do if ch=s[i] then begin p:=1; break; end; if p=0 then begin writeln('NO'); halt end; while (not (eof))and(k1<>0) do begin read(ch); p:=0; if ch<#27 then continue; for i:=1 to 17 do if ch=s[i] then begin p:=1; break; end; if p=0 then begin writeln('NO'); halt end; if ch='(' then begin read(ch); while (ch<#27)and(not (eof)) do read(ch); if ch='*' then begin KOMEN(ch); if eof then break; end else begin inc(k1); p:=0; for i:=1 to 17 do if ch=s[i] then begin p:=1; break; end; if p=0 then begin writeln('NO'); halt end; if ch=')' then dec(k1); if ch='(' then inc(k1); end; end else if ch=')' then begin dec(k1); if k1=0 then break end; end; if eof then break; end; end else if ch='*' then begin read(ch); r:=1; while (ch<#27)and(not (eof)) do read(ch); if ch=')' then begin dec(k2); if k2<0 then break; end; end else if ch=')' then begin r:=1; dec(k1); if k1<0 then break; end; end; if (k1<>0)or(k2<>0) then writeln('NO') else writeln('YES'); END. Help me please! Thanks, very mach! P.S. Sory for my English |
|
|