设计一个算法判断单链表中元素是否是递增的。
bool IsIncrease(LinkList * head){
if(head == NULL || head -> next == NUL)
return true;
else{
for(p=head,q=head->next;q!=NULL;p=q,q=q->next){
if(p->data>q->data)
return false;
}
return true;
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)