#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!");
}用线性表进行回文串的判断
最新推荐文章于 2022-11-07 19:05:27 发布
本文介绍了一个使用 C 语言编写的简单程序,该程序能够从用户输入的一系列整数中判断是否为回文数。通过定义一个队列结构并利用其先进先出的特点,程序实现了对输入数字的前后对比。
934

被折叠的 条评论
为什么被折叠?



