关于即时输出的问题我输到)时怎么不能即时输出C/C++ code#include stack#include iostream#include
关于即时输出的问题
我输到')'时怎么不能即时输出
- C/C++ code
#include <stack>#include <iostream>#include <string>using namespace std;int main(){ char t; int count=0; stack<char> stk; while(cin>>t) { stk.push(t); if(t=='(') ++count; if(count&&t==')') { cout <<endl; while(stk.top()!='(') { cout <<stk.top()<<" "; stk.pop(); } cout <<stk.top()<<endl; stk.pop(); --count; } } while(stk.empty()!=true) { cout <<stk.top()<<" "; stk.pop(); } cout <<endl; return 0;}[解决办法]
说实话,你的程序是用来做括号匹配吗???你说不能输出的问题,我看没有,输出是有的,但就是
不知道你的怎么结束输入........
还有你的输出是这样的:“ )( ”,如果是括号匹配的话,顺序貌似反了,我也不知道你写这程序的
初衷是什么...
[解决办法]
[解决办法]
