回文数的判定,帮忙改一下,谢谢
#include<stdio.h>#include<malloc.h>
typedef struct ploynode
{
int date;
struct ploynode *next;
} *pnode;
pnode creat()
{
int m=0;
int n;
pnode head,p,s;
head=(pnode)malloc(sizeof( struct ploynode));
head->next=NULL;
p=head;
scanf("%d",&n);
while(n!='#')
{
s=(pnode)malloc(sizeof( struct ploynode));
s->date=n;
s->next=NULL;
p->next=s;
p=s;
m=m+1;
scanf("%d",&n);
}
head->date=m;
return(head);
}
pnode stack (pnode head)
{
int i,j;
pnode top,p;
j=head->date;
for(i=1;i<=j/2;j++)
{
top=(pnode)malloc(sizeof( struct ploynode));
p->date=head->date;
head=head->next;
p->next=top->next;
top->next=p;
}
return(top);
}
void bj(pnode p1,pnode p2)
{
int x,y,i;
x=p1->date;
y=p1->date%2;
p1=p1->next;
p2=p2->next;
for(i=1;i<=x/2;i++)
{
p1=p1->next;
}
switch(y)
{
case 1:
p1=p1->next;
while(p1->next!=NULL)
{
if (p1->date==p2->date)
{p1=p1->next;
p2=p2->next;}
else break;
}
if(p1->next==NULL)
printf("ok");
else printf("error");
break;
case 0:
while(p1->next!=NULL)
{
if (p1->date==p2->date)
{p1=p1->next;
p2=p2->next;}
else break;
}
if(p1->next==NULL)
printf("ok");
else printf("error");
break;
default: printf("no");
}
}
int main()
{
pnode p1,p2;
printf("p1:\n");
p1=creat();
printf("d");
p2=stack(p1);
bj(p1,p2);
}