CHAPTER11-11.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER11-11.cpp
- #include <vector>
- #include <algorithm>
- #include <iostream>
- bool greater5 ( int value )
- { return value >5;}
- int main( ) {
- using namespace std;
- vector <int> v1, v2;
- vector <int>::iterator Iter1, Iter2;
- int i;
- for ( i = 0 ; i <= 10 ; i++ ) { v1.push_back( i ); }
- random_shuffle( v1.begin( ), v1.end( ) );
- cout << "Vector v1 is ( " ;
- for ( Iter1 = v1.begin( ) ; Iter1 != v1.end( ) ; Iter1++ ) cout << *Iter1 << " ";
- cout << ")." << endl;
- // Partition the range with predicate greater10
- partition ( v1.begin( ), v1.end( ), greater5 );
- cout << "The partitioned set of elements in v1 is: ( " ;
- for ( Iter1 = v1.begin( ) ; Iter1 != v1.end( ) ; Iter1++ ) cout << *Iter1 << " ";
- cout << ")." << endl;
- }