list<int>::iterator mid(list<int>::iterator beg, list<int>::iterator end){ while(beg!=end){ end--; if(beg==end) return beg; beg++; } if(beg==end) return beg; }
list<int>::iterator mid(list<int>::iterator beg, list<int>::iterator end){ return beg + (end - beg)/2; }
std::list<int>::iterator mid( std::list<int>::iterator beg, std::list<int>::iterator end ) { std::list<int>::difference_type dif = distance( beg, end ); std::advance( beg, dif/2 ); return beg; } const_iterator的也一样