调用equal函数后,涉及到equal函数的语句不运行

您所在的位置:网站首页 链表题目c语言 调用equal函数后,涉及到equal函数的语句不运行

调用equal函数后,涉及到equal函数的语句不运行

#调用equal函数后,涉及到equal函数的语句不运行| 来源: 网络整理| 查看: 265

问题:建表输出正常,但是调用equal函数后不输出不运行,是哪里写的不对吗?题目:判断循环双链表L是否对称

#include #include typedef int ElemType; typedef struct DLnode { int data; struct DLnode *next; struct DLnode *prior; }DLinkNode; void InitList(DLinkNode *&L) { L=(DLinkNode *)malloc(sizeof(DLinkNode)); L->prior=L->next=NULL; } void CreatList(DLinkNode *&L,int a[],int n) { DLinkNode *p,*r; L=(DLinkNode *)malloc(sizeof(DLinkNode)); r=L; for(int i=0;idata=a[i]; r->next=p; p->prior=r; r=p; } r->next=NULL; } void DispList(DLinkNode *&L) { DLinkNode *p=L->next; while(p!=NULL) { printf("%d ",p->data); p=p->next; } } bool equal(DLinkNode *L) { bool same=true; DLinkNode *p=L->next,*q=L->prior; while(same) { if(q->data!=p->data) same=false; else { if(p==q||p->next==q) break; p=p->next; q=q->prior; } } return same; } int main() { DLinkNode *L; int a[7]; InitList(L); printf("请输入:"); for(int i=0;i


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3