# include < iostream.h>
# include < stdlib.h >
consst int stackmaxsize = 30;
typedef int elemtype;
struct stack {
elemtype stack [stackmaxsize];
int top;
};
# include “stack.h”
Void main ( )
{
stack a;
initstack(a);
int x;
cin >>x;
while (x! = -1) {
push (a, x );
cin >>x;
}
while (!stackempty (a))
cout <<pop (a) <<”” ;
cout <<end1;
}
该算法的输出结果为:
点点赞赏,手留余香
给TA打赏
评论0