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;
}
愿你出走半生,归来仍是少年

浙公网安备 33010602011771号