|
|
вернуться в форумProblem with input Послано Sid 16 апр 2005 12:21 It's strange i got wa#1 and i sappose that first test isn't difficult... so perhaps I have problem whith input... #include <stdio.h> #include <iostream.h> int main() { char ar[10000]; char c,c2; bool comment=false; int arifm=0,i=0,t; //FILE* f; //f=fopen("input.txt","r"); while (scanf("%c",&c)!=EOF) { ar[i]=c; i++; } for (t=0;t<i;t++) { if (comment && ar[t]=='*' && t<i-1 && ar[t+1]==')') { if (!comment) { cout<<"NO"<<"\n"; return 0; } comment=false; t++; } else if (!comment) { if (ar[t]=='(') { if (t<i-1 && ar[t+1]=='*') { comment=true; t++; } else arifm++; } else if (ar[t]==')') { arifm--; if (arifm<0) { cout<<"NO"<<"\n"; return 0; } }else if (arifm>0) { if (!((ar[t]>=48 && ar[t]<=57)||ar[t]=='*'||ar[t]=='/'||ar[t]=='+'||ar[t]=='-'||ar[t]=='=')) { cout<<"NO"<<"\n"; return 0; } }
} } if (arifm==0&& !comment) { cout<<"YES"<<"\n"; return 0; } else { cout<<"NO"<<"\n"; return 0; } } |
|
|