#include <iostream>
using namespace std;
#define ElemType int
#define maxSize 100
typedef struct {
ElemType data[maxSize];
int top;
}seqStack;
void initSeqStack(seqStack &S) {
S.top = 0;
}
bool pushSeqStack(seqStack &S, ElemType e) {
if(S.top == maxSize) return false;
else {
S.data[S.top ++] = e;
return true;
}
}
bool popSeqStack(seqStack &S, ElemType &e) {
if(S.top == 0) return false;
else {
e = S.data[-- S.top];
return true;
}
}
bool isEmptySeqStack(seqStack S) {
if(S.top == 0) return true;
else return false;
}
bool isFullSeqStack(seqStack S) {
if(S.top == maxSize) return true;
else return false;
}
bool getTopSeqStack(seqStack S, ElemType &e) {
if(isEmptySeqStack(S)) return false;
else {
e = S.data[S.top - 1];
return true;
}
}
int main() {
seqStack S;
initSeqStack(S);
int a[] = {1, 2, 3, 4, 5, 6, 7};
for(int i = 0; i < 7; i ++) {
pushSeqStack(S, a[i]);
}
ElemType e;
getTopSeqStack(S, e);
while(popSeqStack(S, e)) {
cout << e << " ";
}
cout << endl;
return 0;
}