大家快来帮我看看通过顺序结构实现栈哪里错了,为什么输出是这样啊?
为什么输出全是000000000000000000000000啊#include "stdafx.h"
#include <iostream>
using namespace std;
#define MaxSize 50
typedef struct
{
int data[MaxSize];
int top;
}Sqstack;
void init(Sqstack *&s)
{
s=new Sqstack();
s->top=-1;
}
bool push(Sqstack *&s,int e)
{
if (s->top=MaxSize-1)
return false;
else
s->top++;
s->data[s->top]=e;
return true;
}
void display(Sqstack *s)
{
for (int i=s->top;i>=0;i--)
cout<<s->data[i];
}
int _tmain(int argc, _TCHAR* argv[])
{
Sqstack *s;
init(s);
push(s,5);
push(s,4);
display(s);
return 0;
}