CHAPTER11-18.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER11-18.cpp
- #include <vector>
- #include <deque>
- #include <algorithm>
- #include <iostream>
- int main( )
- {
- using namespace std;
- vector <int> v1;
- deque <int> d1;
- vector <int>::iterator v1Iter1;
- deque<int>::iterator d1Iter1;
- int i;
- for ( i = 0 ; i <= 5 ; i++ ) { v1.push_back( i ); }
- int ii;
- for ( ii =4 ; ii <= 9 ; ii++ ) { d1.push_back( 6 ); }
- cout << "Vector v1 is ( " ;
- for ( v1Iter1 = v1.begin( ) ; v1Iter1 != v1.end( ) ;v1Iter1 ++ ) cout << *v1Iter1 << " ";
- cout << ")." << endl;
- cout << "Deque d1 is ( " ;
- for ( d1Iter1 = d1.begin( ) ; d1Iter1 != d1.end( ) ;d1Iter1 ++ )cout << *d1Iter1 << " ";
- cout << ")." << endl;
- swap_ranges ( v1.begin ( ) , v1.end ( ) , d1.begin ( ) );
- cout << "After the swap_range, vector v1 is ( " ;
- for ( v1Iter1 = v1.begin( ) ; v1Iter1 != v1.end( ) ;v1Iter1 ++ ) cout << *v1Iter1 << " ";
- cout << ")." << endl;
- cout << "After the swap_range deque d1 is ( " ;
- for ( d1Iter1 = d1.begin( ) ; d1Iter1 != d1.end( ) ;d1Iter1 ++ ) cout << *d1Iter1 << " ";
- cout << ")." << endl;
- }