HDU 1870 愚人节的礼物

题解:简单的数括号问题……

#include <cstdio> 
char s[1005];
int main(){
    while(scanf("%s",s)!=EOF){
        int top=0;
        for(int i=0;;i++){
            if(s[i]=='B')break;
            if(s[i]=='(')top++;
            if(s[i]==')')top--;
        }
        printf("%d\n",top);
    }
    return 0;
}
posted @ 2014-04-18 11:23  forever97  阅读(114)  评论(0编辑  收藏  举报