#include "SeqStack.h"//堆栈头文件

void isHuiWen(int str[], int n)
{
    SeqStack s;
    int x;//出栈值
    StackInitiate(&s);//初始化堆栈
    for (int i = 0; i < n; i++)
    {
        StackPush(&s, str[i]);//数组入栈
    }
    for (int i = 0; i < n; i++)
    {
        StackPop(&s, &x);
        if (str[i] != x)//数组第i个元素和栈顶元素是否相等
        {
            printf("不是回文\n");
            return;
        }
    }
    printf("是回文\n");

}
int main()
{
    a[5] = { 1,2,3,2,1 };
    isHuiWen(a, 5);
    return 0;
}

//运行结果:是回文
网络上志同道合,我们一起学习网络安全,一起进步,QQ群:694839022