| 
 | 
вернуться в форумI don't belive my cole get WA.plz help. program t1027; {const fin='f:\temp\in4.txt';} var i,j,pp,n,k:longint;     ch:char;     str:array[1..10000] of char;     t,tt:boolean; begin {     assign(input,fin);      reset(input);}      j:=1;      while not (ch=#26) do            begin            read(ch);            str[j]:=ch;            inc(j);            end;      n:=j-1; i:=0;      repeat          inc(i);          j:=i;          if str[i]='(' then             if str[i+1]='*' then                begin                     t:=false;                     for j:=i+2 to n do if (str[j]='*')and(str[j+1] =')') then                         t:=true;                     if t=false then begin writeln('NO'); tt:=false; halt; end                        else i:=j+2;                     j:=0;                end             else begin                  pp:=1;                  repeat                        inc(j);                        if not(str[j] in ['(',')','0'..'9','+','- ','*','/','='])                           then begin writeln('NO'); tt:=false; halt; end;                        if (str[j]='*')and(str[j-1]='(') then                           begin                           dec(pp);                           for k:=j+1 to n do                               if (str[k]='*')and(str[k+1]=')') then                                  begin j:=k+2; break; end;                           if k>=n then begin writeln('NO'); tt:=false; halt; end;                           end;                        if str[j]=')' then dec(pp);                        if pp=0 then break;                        if str[j]='(' then inc(pp);                  until j>=n;                  if pp<>0 then begin writeln('NO'); tt:=false; halt; end;                  i:=j+1;                  end;      until i>=n;      if tt then writeln('YES'); {     close(input);} end.  |  
  | 
|