int main()
{
LinkList *A, *B;
int i;
ElemType a[]= {1, 3, 2, 9};
ElemType b[]= {0, 4, 5 ,6, 7, 8};
InitList(A);
for(i=3; i>=0; i--)
ListInsert(A, 1, a[i]);
InitList(B);
for(i=5; i>=0; i--)
ListInsert(B, 1, b[i]);
printf("A: %c\n", increase(A)?'Y':'N');
printf("B: %c\n", increase(B)?'Y':'N');
DestroyList(A);
DestroyList(B);
return 0;
}
bool increase(LinkList *l)
{
LinkList *p;
int a;
p=l;
p=p->next;
a=p->data;
p=p->next;
while(p!=NULL)
{
if(p->data>=a)
{
a=p->data;
}
else return false;
p=p->next;
}
return true;
}
第四周项目3 单链表应用3
最新推荐文章于 2017-12-14 10:43:02 发布