📄 stack.cpp
字号:
// stack.cpp: implementation of the stack class.
//
//////////////////////////////////////////////////////////////////////
#include "stack.h"
#include "iostream.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
stack::stack()
{s->top=-1;
}
stack::~stack()
{
}
bool stack::push_stack(int t)
{if (s->top==MAX-1)
return false;
else
{s->top++;
s->data[s->top]=t;
return true;
}
}
bool stack::pop_stack(int p)
{if (s->top==-1)
return false;
else
{p=s->data[s->top];
s->top--;
return true;
}
}
void stack::mybag(int v,int n)
{ int sum;
for(int j=-1;j<=n-1;j++)
{if (sum=v)
{for(int i=0;i<=s->top;i++)
cout<<s->data[i] ;
this->pop_stack(x);
cout<<endl;
}
else
{if(sum<v)
{this->push_stack(d[j+1]);
sum+=d[j+1];
}
else
this->pop_stack(d[j]);
sum=sum-d[j];
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -