#include<stdio.h>
#include<stdlib.h>
#define max 100
typedef struct{
char data[max];
int top;
}Stack;
void CreateStack(Stack* &s)//栈的创建
{
s=(Stack*)malloc(sizeof(Stack));
s->top=-1;
}
bool PushStack(Stack* &s,char a[])//入栈
{
int i=0;
if(s->top==max-1)
return false;
while(a[i]!='\0')
{
s->top++;
s->data[s->top]=a[i];
i++;
}
return true;
}
void PopStack(Stack* &s,char a[])//出栈
{
int i=0;
while(s->data[s->top]==a[i])//判断字符串
{
s->top--;
i++;
}
if(s->top<i)
printf("该字符串是回文字符串");
else
printf("该字符串不是字符串");
}
void DestoryStack(Stack* &s)//销毁栈
{
free(s);
}
int main()
{
char str[max];
Stack* S;
printf("请输入字符串:\n");
scanf("%s",&str);
CreateStack(S);
PushStack(S,str);
PopStack(S,str);
DestoryStack(S);
return 0;
}