📄 chapter8-34.cpp
字号:
//文件名:CHAPTER8-34.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;
list <int>::iterator c1_Iter, c2_Iter, c3_Iter;
c1.push_back( 3 );
c1.push_back( 6 );
c2.push_back( 2 );
c2.push_back( 4 );
c3.push_back( 5 );
c3.push_back( 1 );
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;
c2.merge( c1 ); // Merge c1 into c2 in (default) ascending order
c2.sort( greater<int>( ) );
cout << "After merging c1 with c2 and sorting with >: c2 =";
for ( c2_Iter = c2.begin( ); c2_Iter != c2.end( ); c2_Iter++ )
cout << " " << *c2_Iter;
cout << endl;
cout << "c3 =";
for ( c3_Iter = c3.begin( ); c3_Iter != c3.end( ); c3_Iter++ )
cout << " " << *c3_Iter;
cout << endl;
c2.merge( c3, greater<int>( ) );
cout << "After merging c3 with c2 according to the '>' comparison relation: 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 + -