Please help me,I try many test,but I get WA on #7
Послано
Lurker 20 июл 2006 08:44
This is me program:
Program D_plus_plus_Again;
Var
ch:char;
z,i:integer;
zs:boolean;
zk,x:array[1..10000] of integer;
Begin
Assign(input,'');reset(input);
zs:=false;
While not(eof(input)) do Begin
inc(i);Read(ch);
If ord(ch)=13 Then begin inc(i);Read(ch) End Else
If not(zs) Then
If z=0 Then Begin
case ch of
'*':if zk[i-1]=1 then zs:=true;
'(':zk[i]:=1;
')':if zk[i-1]=0 then begin writeln('NO');halt;end;
End;
If zk[i-1]=1 then if ch<>'*' then Begin
Inc(z);
case ch of
'(':Begin inc(z);zk[i]:=1;end;
')':if (x[i-1]=1) or (z=0) then begin writeln('NO');halt;end Else Dec(z);
'*':If zk[i-1]=1 then Begin dec(z);zs:=true;End Else x[i]:=1;
'=','+','-','/','0','1','2','3','4','5','6','7','8','9':i:=i;
Else Begin writeln('NO');halt;end;
end
End;
End Else
case ch of
'(':Begin inc(z);zk[i]:=1;end;
')':Dec(z);
'*':If zk[i-1]=1 then Begin dec(z);zs:=true;x[i]:=1;End Else x[i]:=1;
'=','+','-','/','0','1','2','3','4','5','6','7','8','9':i:=i;
Else Begin writeln('NO');halt;end;
end
Else case ch of
')':if x[i-1]=1 then zs:=false;
'*':x[i]:=1;
End;
End;
If zs or (z<>0) then writeln('NO') Else writeln('YES');
close(input);
End.