|
|
back to boardWHY I Get CE??????????????? NEED HELP!!!!!!!!!!!!!!! I can run in my delphi6 but CE here!!!!!!!!! The judge system must see it ---------------------------------------------------- program Project2; {$APPTYPE CONSOLE} const setchar=['(',')','=','+','-','*','/','0'..'9','*']; var i,j,pp,n,k:longint; ch:char; str:array[0..10000] of char; t:boolean; begin i:=0; while not eof do begin read(ch); inc(i); str[i]:=ch; end; n:=i; 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'); halt; end else i:=j+2; j:=0; end else begin pp:=1; repeat inc(j); if str[j] in setchar then begin end else begin writeln('NO'); halt; end; if (str[j]='*')and(str[j-1]='(') then begin dec(pp); for k:=j to n do if (str[k]='*')and(str[k+1]=')') then begin j:=k+2; break; end; if k>=n then begin writeln('NO'); 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'); halt; end; i:=j+1; end; until i>=n; writeln('YES'); readln; end. Submit it via E-mail and you can where's error. Read the FAQ if you don't know how (-) My English is poor, can you say a little clearly > when u choose "reply to my e-mail",Judge will tell u why it's get ce(-) > > Thanks, and I know where CE. But I got WA. Please Help Here is my cole program t1027; {const fin='f:\temp\in4.txt';} var i,j,pp,n,k:longint; ch:string; str:array[1..10000] of char; t:boolean; begin { assign(input,fin); reset(input);} j:=1; while not eof do begin readln(ch); for i:=1 to length(ch) do begin str[j]:=ch[i]; inc(j); end; end; n:=j; 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'); 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'); 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'); 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'); halt; end; i:=j+1; end; until i>=n; writeln('YES'); { close(input);} end. Re: Thanks, and I know where CE. But I got WA. Please Help compile my code and test ur prog :) i think this prob description is not clear #include <stdio.h> #include <ctype.h> FILE *fp,*fx; int main() { long false,com=0,sum=0; char kao,chr; fp=stdin; fx=stdout; // fp=fopen("1027.in","r"); fx=fopen("1027.out","w"); false=0; kao=0; while(fscanf(fp,"%c",&chr)!=EOF) { if(com&&chr==')'&&kao=='*') com=0; else if(!com&&chr==')'&&kao=='*'&&!sum) false=1; else if(!com&&chr==')'&&kao=='*'&&sum) sum--; else if(!com) { if(chr=='(') sum++; else if(chr=='*'&&kao=='(') { sum--; com=1; chr=0; } else if(chr==')') sum--; else if(sum>0&&!(isdigit(chr) ||chr=='\r'||chr=='\n'||chr=='='||chr=='+'||chr=='- '||chr=='*'||chr=='/')) false=1; } if(false||sum<0) break; kao=chr; } if(false||sum>0||sum<0||com) fprintf(fx,"NO\n"); else fprintf(fx,"YES\n"); // fclose(fp); fclose(fx); return 0; } Thank you anyway.But I didn't know C or C++ If you can test my cole and find my bugs, thanks a lot. Mail me Walter_ddr@hotmail.com |
|
|