#include "algostuff.hpp"
using namespace std;
int main()
{
 vector<int> coll1;
 list<int> coll2;
 INSERT_ELEMENTS(coll1,1,6);
 for(int i=1;i<=16;i*=2)
 {
  coll2.push_back(i);
 }
 coll2.push_back(3);
 PRINT_ELEMENTS(coll1,"coll1: ");
 PRINT_ELEMENTS(coll2,"coll2: ");

 pair<vector<int>::iterator,list<int>::iterator> values;
 values=mismatch(coll1.begin(),coll1.end(),coll2.begin());
 if(values.first==coll1.end())
 {
  cout<<"no mismath"<<endl;
 }
 else
 {
  cout<<"first mismath: "
   <<*values.first<<" and "
   <<*values.second<<endl;
 }

 values=mismatch(coll1.begin(),coll1.end(),coll2.begin(),less_equal<int>());

//第一序列的元素比第二序列的元素大,找到后,返回该两个值、
 if(values.first==coll1.end())
 {
  cout<<"always less-or-equal: "<<endl;
  
 }
 else
 {
  cout<<"not less-or-equal: "
   <<*values.first<<" and "
   <<*values.second<<endl;
 }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////

output:

coll1: 1 2 3 4 5 6
coll2: 1 2 4 8 16 3
first mismath: 3 and 4
not less-or-equal: 6 and 3
Press any key to continue

posted on 2010-04-17 20:25  蓝牙  阅读(316)  评论(0编辑  收藏  举报