#include 
const int max = 5;
float num[max];
int top = 0;
void push(float x)
	{
	if (top==max){return;}		
        num[top] = x;//
        top++;
	}

void  pop()
	{
	top--;
//	if (top<0){return 0;};
        cout<< num[top];
	//top--;
	}


void main()
{
float x;

for (int j=0;j>x;
push(x);
cout<<"top"<


1 入栈:判断是否满,若不满,栈顶指针加1,再入栈。

2 出栈: 判断是否为空,若不空,先返回栈顶元素,再将栈顶指针减1。