UVa 673 - Parentheses Balance
2014-05-02 16:43
417 查看
传送门UVa 673 - Parentheses Balance
题意是判断括号是否合法.
水题.
回想起两个月前我第一次看到这种题目时想的那个绞尽脑汁啊......最后还TLE了╮(╯▽╰)╭
UVa挂了, 先贴代码. 应该没错.
-------------------------------------------------------------------------------------------------------------
AC.
题意是判断括号是否合法.
水题.
回想起两个月前我第一次看到这种题目时想的那个绞尽脑汁啊......最后还TLE了╮(╯▽╰)╭
UVa挂了, 先贴代码. 应该没错.
-------------------------------------------------------------------------------------------------------------
AC.
#include <cstdio> #include <stack> using namespace std; int main() { //freopen("input.txt", "r", stdin); stack<char> in; int n; char c; scanf("%d", &n); getchar(); while (n--) { while ((c = getchar()) != '\n') { if (!in.empty()) { if (c == ']' && in.top() == '[' || c == ')' && in.top() == '(') in.pop(); else in.push(c); } else in.push(c); } if (in.empty()) printf("Yes\n"); else printf("No\n"); while (!in.empty()) in.pop(); } return 0; }
相关文章推荐
- 【STL基础02】UVA-673-Parentheses Balance
- 【UVa 673】Parentheses Balance
- Parentheses Balance-UVA - 673
- uva-673 Parentheses Balance
- UVa 673 - Parentheses Balance
- UVA - 673 Parentheses Balance
- UVa 673 Parentheses Balance
- UVa 673 Parentheses Balance(栈的使用)
- UVa 673 Parentheses Balance
- UVA673 - Parentheses Balance
- UVA - 673 Parentheses Balance
- UVa-673-Parentheses Balance
- UVa 673 - Parentheses Balance
- UVA - 673 - Parentheses Balance
- UVA-673 Parentheses Balance
- uva 673 Parentheses Balance 【栈】
- UVa 673 Parentheses Balance
- UVa673 - Parentheses Balance
- UVa - 673 - Parentheses Balance(栈-stack)(Java和C++)
- UVa-673-Parentheses Balance