#include <iostream>
using namespace std;
#define N 10
int stackdata[N];
int top = -1;
int push(int n)
{
if (top < N - 1)
{
top++;
stackdata[top] = n;
return 1;
}
return -1;
}
int pop()
{
int r;
if (top > -1)
{
r = stackdata[top];
stackdata[top] = 0;
top--;
return r;
}
return -1;
}
int main(int argc, char** argv)
{
push(1);
push(3);
pop();
push(9);
push(9);
push(3);
for (int i = 0; i <= top; i++)
{
cout << stackdata[i] << " ";
}
cout << endl;
return 0;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น