zoukankan      html  css  js  c++  java
  • The Balance of the World Aizu

    题目链接:https://vjudge.net/problem/Aizu-1173

    题解:简单模拟一下过程就好了。

    AC代码:

    #include<iostream>
    #include<stack>
    #include<vector>
    #include<cstdlib>
    #include<string>
    #include<cstdio>
    #include<algorithm>
    using namespace std;
    
    int main()
    {
        string C;
        while (1)
        {
            stack<char>S;
            getline(cin, C);
            if (C[0] == '.')
                break;
            else
            {
                int ant = 0;
                for (int i = 0; i < C.length(); ++i)
                {
                    if (C[i] == '(' || C[i] == '[')
                        S.push(C[i]);
                    else if (C[i] == ')')
                    {
                        if (!S.empty() && S.top() == '(')
                            S.pop();
                        else 
                            ant = 1;
                    }
                    else if (C[i] == ']')
                    {
                        if (!S.empty() && S.top() == '[')
                            S.pop();
                        else
                            ant = 1;
                    }
                    if (ant)
                        break;
                }
                if (!ant && S.empty())
                    cout << "yes" << endl;
                else
                    cout << "no" << endl;
            }
        }
        return 0;
    }

    今天也是元气满满的一天!good luck! 

  • 相关阅读:
    总结
    kafka
    kafka前传 JMS
    currentHashMap
    mapPartitionsWithIndex foreachPartitionAsync foreachPartition
    hbase
    hive
    zookeeper kafka storm
    flume的简单使用
    spring-data-jpa
  • 原文地址:https://www.cnblogs.com/cattree/p/9379653.html
Copyright © 2011-2022 走看看