顺序栈判断回文的问题,高手帮忙看哈
#include<stdio.h>#include<string.h>
#define n 10
typedef struct
{
char data[n];
int top;
}seqstack;
void stackinitial(seqstack *ps)
{
ps->top=-1;
}
int isempty(seqstack *ps)
{
return ps->top==-1;
}
int isfull(seqstack *ps)
{
return ps->top>=n-1;
}
void push(seqstack *ps,int e)
{if(isfull(ps))
{
printf("栈已满\n");
exit(1);
}
ps->data[++ps->top]=e;
}
char pop(seqstack *ps)
{
if(isempty(ps))
{
printf("空栈!\n");
exit(1);
}
return ps->data[ps->top--];
}
int pair(char a[])
{
int i=0;
char ch,temp;
seqstack q;
stackinitial(&q);
while(ch=a[i++]!='\0')
push(&q,ch);
i=0;
while(!=isempty(&q))
{
temp=pop(&q);
if(temp!=a[i++])
return 0;
}
return 1;
}
void main()
{
char a[n];
int i,j;
printf("input string\n");
for(i=0;i<n;i++)
scanf("%c",&a[i]);
j=pair(a);
if(j==1)
printf("是回文:\n");
for(i=0;i<n;i++)
printf("%c",a[i]);
}
老是出现这样的错误: warning C4013: 'exit' undefined; assuming extern returning int
D:\Vc\c程序\c语言\c++\03.c(53) : error C2059: syntax error : '!='
D:\Vc\c程序\c语言\c++\03.c(59) : error C2059: syntax error : 'return'
D:\Vc\c程序\c语言\c++\03.c(60) : error C2059: syntax error : '}'
Error executing cl.exe.
03.obj - 3 error(s), 1 warning(s)