b*****d 发帖数: 23 | 1 #include
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a[] = {1,2,3,4,5,6,7};
stack stack1;
stack stack2;
for(int i = 0; i<7; ++i)
stack1.push(a[i]);
int i = stack1.size();
while(!stack1.empty())
{
for(int j = 0; j
{
stack2.push(stack1.top());
stack1.pop();
}
in | b*****d 发帖数: 23 | 2 the code works fine, but with comeplxity N^2.
BTW, 不能用辅助 stack.
【在 b*****d 的大作中提到】![](/moin_static193/solenoid/img/up.png) : #include : using namespace std; : int _tmain(int argc, _TCHAR* argv[]) : { : int a[] = {1,2,3,4,5,6,7}; : stack stack1; : stack stack2; : for(int i = 0; i<7; ++i) : stack1.push(a[i]); : int i = stack1.size();
|
|