作业帮 > 综合 > 作业

判断是否是回文

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/17 20:05:30
判断是否是回文
Sequenlist *L;
L=(Sequenlist
*)malloc(sizeof(Sequenlist));
L->last=-1;return L;}Seqstack * Setstack(){ //建空栈
Seqstack *S;
S=(Seqstack *)malloc(sizeof(Seqstack));S->top=-1;return S;}Seqstack * Pushstack(char x,Seqstack
*S){ //入栈S->top++;S->data[S->top]=x;return S;}Seqstack * Popstack(Seqstack *S){ //出栈S->top--;return S;}char Gettop(Seqstack *S){ //取栈顶
return S->data[S->top];}Sequenlist *Pushlist(){ //将字符串存入顺序表中Sequenlist *L;
L=Sqlsetnull();char a;printf("请输入字符串,并以'#'结束!\n");
a=getchar();
while(a!='#'){L->last++;L->ch[L->last]=a;
a=getchar();}return L;}int Compare(Sequenlist *L){ //判断是不是回文int i,n;
n=(L->last+1)/2;
Seqstack *S;
&&L->last!=-1){L->last--;S=Popstack(S);}if(L->last==-1) //是回文返回1return 1;else //不是回文返回0return 0;}void Resultout(int a){ //结果输出if(a==1)printf("该字符串是回文!\n");if(a==0)printf("该字符串不是回文!\n");}void main(){