php做网站怎么样培训心得体会800字
遍历字符串吗,如果,后一个和站的top一样,就弹出,不一样,就入栈;
如果栈为空,输出0;
最后,把栈里的元素反向输出即可
#include<bits/stdc++.h>
using namespace std;int main()
{string s; string result;cin>>s;stack<char>st;for(auto c:s){if(!st.empty()&&c==st.top()){st.pop();}else {st.push(c);}}if(st.empty()){cout<<"0";}else {while(!st.empty()){result=st.top()+result;st.pop();}cout<<result;}return 0;
}