bool f(int push[], int pop[], unsigned int length)
{
if(length==0) return false;
int j=0; stack<int> st;
for(int i=0; i<length; i++)
{
if(j<length)
{
if(st.size()==0)
{
while(pop[i]!=push[j] && j<length)
{
st.push(push[j++]);
}
if(j==length && pop[i]!=st.top())
return false;
st.push(push[j++]);
int top=st.top();
if(pop[i]==top)
{
st.pop();
continue;
}
}
if(st.size()>0)
{
while(pop[i]!=st.top() && j<length)
{
st.push(push[j++]);
}
if(j==length && st.top()!=pop[i])
return false;
int top=st.top();
if(pop[i]==top)
{
st.pop();
continue;
}
}
}
else
{
int top=st.top();
if(pop[i]!=top)
return false;
else
{
st.pop();
}
}
}
return true;
}
递归可否????