📄 chapter8-38.cpp
字号:
//文件名:CHAPTER8-38.cpp
#include <list>
#include <iostream>
#if _MSC_VER > 1020 // if VC++ version is > 4.2
using namespace std; // std c++ libs implemented in std
#endif
int main( )
{
list <int> c1, c2, c3, c4;
list <int>::iterator c1_Iter, c2_Iter, w_Iter, f_Iter, l_Iter;
c1.push_back( 10 );
c1.push_back( 11 );
c2.push_back( 12 );
c2.push_back( 20 );
c2.push_back( 21 );
c3.push_back( 30 );
c3.push_back( 31 );
c4.push_back( 40 );
c4.push_back( 41 );
c4.push_back( 42 );
cout << "c1 =";
for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
cout << " " << *c1_Iter;
cout << endl;
cout << "c2 =";
for ( c2_Iter = c2.begin( ); c2_Iter != c2.end( ); c2_Iter++ )
cout << " " << *c2_Iter;
cout << endl;
w_Iter = c2.begin( );
w_Iter++;
c2.splice( w_Iter,c1 );
cout << "After splicing c1 into c2: c2 =";
for ( c2_Iter = c2.begin( ); c2_Iter != c2.end( ); c2_Iter++ )
cout << " " << *c2_Iter;
cout << endl;
f_Iter = c3.begin( );
c2.splice( w_Iter,c3, f_Iter );
cout << "After splicing the first element of c3 into c2: c2 =";
for ( c2_Iter = c2.begin( ); c2_Iter != c2.end( ); c2_Iter++ )
cout << " " << *c2_Iter;
cout << endl;
f_Iter = c4.begin( );
l_Iter = c4.end( );
l_Iter--;
c2.splice( w_Iter,c4, f_Iter, l_Iter );
cout << "After splicing a range of c4 into c2: c2 =";
for ( c2_Iter = c2.begin( ); c2_Iter != c2.end( ); c2_Iter++ )
cout << " " << *c2_Iter;
cout << endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -