maxStack->push_back(0); } else { DataStack->push_back(data); int minIndex = *(minStack->end()-1); int maxIndex = *(maxStack->end()-1); int min = *(DataStack->begin() + minIndex); int max = *(DataStack->begin() + maxIndex); if (min > data) { minStack->push_bac...
解析 在带头结点的单链表L中,删除值大于mink且小于maxk的所有元素。 int del(LinkList L,int mink,int maxk) { LinkList p,q; for(q=L,p=L->next;p!=NULL;p=q->next) { if(p->data>mink&&p->data { q->next=p->next; free(p); } else q=p; } return 0; } 时间复杂度为O(n)。
maxStack->push_back(0); } else { DataStack->push_back(data); int minIndex = *(minStack->end()-1); int maxIndex = *(maxStack->end()-1); int min = *(DataStack->begin() + minIndex); int max = *(DataStack->begin() + maxIndex); if (min > data) { minStack->push_bac...