入栈程序
void Push(sqstack* s, Elemtype e) //入栈
{
if (s->top == Max - 1) {
printf("full\n");
return;
}
s->top++;
s->data[s->top].x = e.x;
s->data[s->top].y = e.y;
s->data[s->top].d = e.d;
}
出栈程序
int Pop(sqstack* s, Elemtype*e) //出栈
{
if (s->top ==- 1) {
printf("stack is empty\n");
return 0;
}
e->x = s->data[s->top].x;
e->y = s->data[s->top].y;
e->d = s->data[s->top].d;
s->top--;
}
为什么入栈函数的形参 是Elemtype e类型 而出栈函数的形参是 Elemtype*e类型呢?
还有e.x 和 e->x 在程序中具体的区别在哪里
代码发完整了吗
typedef struct //定义坐标
{
int x, y;
}item;
typedef struct //顺序栈元素
{
int x, y, d;//d表示下一方向
}Elemtype;
typedef struct//栈的类型定义
{
Elemtype data[Max];
int top;
}sqstack;
不知道你这个问题是否已经解决, 如果还没有解决的话: