首页 > 其他 > 详细

hdu1870 愚人节的礼物

时间:2014-04-11 10:30:14      阅读:447      评论:0      收藏:0      [点我收藏+]

题目:点击打开链接


今个儿携程要是这么简单就好了。。

不是‘(’就是‘)’,如果出现了B,那么清空栈,最后+1取相反数。其实根本用不着存进去- -。。直接假装有个栈就行。。

The reason I wrote it is I feel traumatized by the competition......TAT

#include <iostream>
using namespace std;

int main()
{
    char str[1001];
    int top, i, j;
    while(cin >> str){
        top = -1;
        for(i = 0; str[i] != ‘\0‘; i++){
            char &ch = str[i];
            if(ch == ‘(‘)
                top++;
            else if(ch == ‘)‘)
                top--;
            else
                top = -1;
        }//end i
        cout << -(top + 1) <<endl;
    }//end str

    return 0;
}



hdu1870 愚人节的礼物,布布扣,bubuko.com

hdu1870 愚人节的礼物

原文:http://blog.csdn.net/svitter/article/details/23388951

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!