|
|
back to boardWA1 This is my code: #include <stdio.h> #define ulong unsigned long void main() { #ifndef ONLINE_JUDGE freopen("in.txt","rt",stdin); freopen("out.txt","wt",stdout); #endif bool comment=0,arithmetical=0; long brakets=0; char syms[10001]; ulong i; while(!feof(stdin)) { gets(syms); i=0; while(syms[i]) { if(comment) { while(syms[i]) { if(syms[i]=='*') { ++i; if(syms[i]==')') { ++i; comment=0; break; } } ++i; } } if(arithmetical) { while(syms[i]) { if(!((syms[i]>=0x28&&syms[i]<=0x2B)||(syms[i]>=0x30&&syms[i]<=0x39)||syms[i]=='-'||syms[i]=='/'||syms[i]=='\n'||syms[i]=='=')) { printf("NO"); return; } if(syms[i]=='(') { ++i; if(syms[i]=='*') { ++i; comment=1; break; } ++brakets; continue; } if(syms[i]==')') { ++i; --brakets; if(!brakets) { arithmetical=0; break; } } ++i; } continue; } while(syms[i]) { if(syms[i]=='(') { ++i; if(syms[i]=='*') { ++i; comment=1; break; } arithmetical=1; ++brakets; break; } if(syms[i]==')') { printf("NO"); return; } ++i; } } } if(arithmetical||comment) { printf("NO"); return; } printf("YES"); } WHY WA1?! Re: WA1 Give me solution for this task, please, i don't understand why i get WA#1 |
|
|