void reverse(Stack *st)
{
if(st->a.top > -1)
{
int temp = pop(st);
reverse(st);
add_bottom(st,temp);
}
}
void add_bottom(Stack*st,int temp)
{
if(st->a.top == -1)
{
push(st,temp);
}
else
{
int t = pop(st);
add_bottom(st,temp);
push(st,t);
}
}
用递归的方法翻转一个栈
最新推荐文章于 2022-02-13 16:05:34 发布