hdu1870 愚人节的礼物
生活随笔
收集整理的這篇文章主要介紹了
hdu1870 愚人节的礼物
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目:點擊打開鏈接
今個兒攜程要是這么簡單就好了。。
不是‘(’就是‘)’,如果出現了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--;elsetop = -1;}//end icout << -(top + 1) <<endl;}//end strreturn 0; }
總結
以上是生活随笔為你收集整理的hdu1870 愚人节的礼物的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 提升团队战斗力的要点
- 下一篇: 通过NTP协议进行时间同步