1 条题解
-
0
C :
#include <stdio.h> main() { char c;int t=0; while ((c=getchar())!='@') { if(c=='(')t++; if(c==')'){ t--; if(t<0)break; } } if (t==0) printf("YES"); else printf("NO"); }
C++ :
#include<iostream> #include<cstring> #include<cstdio> #include<stack> using namespace std; string s; stack<char> a; bool my_judge(string); int main() { cin>>s; if(my_judge(s))cout<<"YES"<<endl; else cout<<"NO"<<endl; return 0; } bool my_judge(string s) { int i=0; while(s[i]!='@') { if(s[i]=='(')a.push(s[i]); if(s[i]==')') { if(a.empty()) return false; a.pop(); } i++; } if(a.empty())return true; else return false; }
- 1
信息
- ID
- 876
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者