#include<stdio.h>
#include<stdlib.h>
#define Maxsize 20
struct DLB
{
char data;
struct DLB *next;
};
struct DLB *Create();
void Pop(struct DLB *L);
int Pan(struct DLB *L);
int main()
{
struct DLB *L;
L=Create();
Pop(L);
Pan(L);
return 0;
}
struct DLB *Create()
{
struct DLB *head=NULL,*p,*p1;
p=(struct DLB *)malloc(sizeof(struct DLB));
printf("请输入链表小写字符串:");
scanf("%c",&p->data );
p->next =NULL;
while(p->data !='Z')
{
if(head==NULL)
{
head=p;
p1=p;
}
else
{
p1->next =p;
p1=p;
}
p=(struct DLB *)malloc(sizeof(struct DLB));
scanf("%c",&p->data );
p->next =NULL;
}
p1->next =NULL;
free(p);
return head;
}
void Pop(struct DLB *L)
{
while(L!=NULL)
{
printf("%3c",L->data );
L=L->next ;
}
putchar('\n');
}
int Pan(struct DLB *L) //判断算法
{
char s[Maxsize];
int i=0;
while(L!=NULL)
{
s[i++]=L->data ;
L=L->next ;
}
s[i]='\0';
int j,k;
for(j=0,k=i-1;j<i/2,k>=i/2;j++,k--)
if(s[j]!=s[k])
{
printf("不关于中心对称\n");
return false;
}
printf("关于中心对称\n");
return true;
}
05-01
801
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-30
4398
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)