用线性表进行回文串的判断
来源:互联网 发布:淘宝如何设置自动回复 编辑:程序博客网 时间:2024/05/17 08:04
#include<stdio.h>main(){ int b=1;typedef struct{ int *base; int front; int rear;}squeue;squeue q;q.base=(int*)malloc(12*sizeof(int));b=1; q.front=0; q.rear=0; printf("fen pei ok!\n"); scanf("%d",&(q.base[q.rear])); printf("fen pei ok!\n"); while(q.base[q.rear]!=0) { q.rear++; scanf("%d",&(q.base[q.rear])); } q.rear--; while((q.rear>=q.front)&&(b>0)) { if(q.base[q.front]!=q.base[q.rear]) { b=-1; printf("%d***\n",q.base[q.rear]); printf("%d",q.base[q.front]); printf("----com---\n"); } else{ q.front++; q.rear--; } } if(b>0) printf("Yes!It is a hui wen shu !"); else printf("No!It is not a hui wen shu!"); }