标签:
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
#define StackSize 100
typedef char DataType;
typedef struct{
DataType data[StackSize];
int top;
}SeqStack;
/*void Int(SeqStack *s){
s->top=-1;
}*/
int judge(SeqStack *s,char *t){
int i,len;
char temp;
len=strlen(t);
for ( i = 0; i <len/2; i++)
{if(s->top<StackSize-1){
s->data[++s->top]=t[i];
}else
{
printf("Stack Overflow");
exit;
}
}
if (len%2==1) i++;
while (s->top>-1)
{
temp=s->data[s->top--];
if (temp!=t[i]) return 0;
else i++;
}
return 1;
}
int main(){
SeqStack *s;
s=(SeqStack*)malloc(sizeof(SeqStack));//注意这里如果是C语言先要初始化,不然会出错。
s->top=-1;
char t[250];
cin>>t;
cout<<judge(s,t)<<endl;
}
标签:
原文地址:http://blog.csdn.net/a819721810/article/details/45457753