程序代码:#include
#include
#include
#define maxsize 100
typedef struct {
int a[maxsize];
int top;
}stack;
void init(stack *st)
{
st->top = -1;//st->top = 0;
}
void push(stack *st,int x)
{
if(st->top==maxsize)
{
printf("the stack is full");
return ;
}
st->top++;
st->a[st->top] = x;
}
char pop(stack *st)
{
char m;
m=st->a[st->top];
st->top=(st->top)-1;
return m;
}
int main()
{
int i;
int nTemp;
int b[] = {1,2,3,5};
int m = (int)sizeof(b)/sizeof(int);
stack a;
init(&a);
for(i=0;i
push(&a,b[i]);
for(i=0;i
{
nTemp = pop(&a);
if(b[i]!=nTemp)
{
printf("不是回文数!\n");
break;
}
}
if(i==m)
printf("是回文数!\n");
return 0;
}