|
|
вернуться в форумWhat's wrong with my program? I got WA /* * URAL 1027 * Wrong Answer */ #include <iostream> #include <string> #include <stdlib.h> using namespace std; void getout() {cout<<"NO"<<endl; exit(0);} int main() { char t[30000]; int incomment=0,arth=0,len,i; while (!cin.eof()) { t[0]=0; cin.getline(t,30000,'\n'); len=strlen(t); for (i=0;i<len;i++) { if (!incomment&&t[i]=='('&&t[i+1]=='*') incomment=1,i++; else if (incomment) { if (t[i]=='*'&&t[i+1]==')') incomment=0,i++; } else { if (t[i]=='(') arth++; else if (t[i]==')') arth--; else if (arth!=0&&!(t[i]=='='||t[i]=='+'||t[i]=='-'||t[i]=='*'||t[i]=='/'||(t[i]>='0'&&t[i]<='9'))) getout(); } if (arth<0) getout; } } if (arth!=0||incomment) getout(); cout<<"YES"<<endl; return 0; } |
|
|