📄 pex5_5.cpp
字号:
#include <iostream.h>
#pragma hdrstop
typedef int DataType;
#include "pex5_5.h" // include definition of DualStack
void main (void)
{
DualStack S;
int i;
int A[20] = {1,2,3,4,5,6,7,-8,-9,10,-11,12,-13,-14,15,16,17,18,0,-20};
// cycle through a. push the even integers on stack 1
// and the odd integers on stack 2
for (i = 0; i < 20; i++)
{
if (A[i] % 2 == 0)
S.Push(A[i], 1);
else
S.Push(A[i],2);
}
// print the two stacks
while (!S.StackEmpty(1))
cout << S.Pop(1) << " ";
cout << endl;
while (!S.StackEmpty(2))
cout << S.Pop(2) << " ";
cout << endl;
}
/*
<Run>
-20 0 18 16 -14 12 10 -8 6 4 2
17 15 -13 -11 -9 7 5 3 1
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -