chapter10-37.cpp
来自「STL程序员开发指南源码」· C++ 代码 · 共 27 行
CPP
27 行
//文件名:CHAPTER10-37.cpp
#include <map>
#include <iostream>
#if _MSC_VER > 1020 // if VC++ version is > 4.2
using namespace std; // std c++ libs implemented in std
#endif
void main( )
{
map <int, int, less<int> > m1;
map <int, int, less<int> >::value_compare vc1 = m1.value_comp( );
pair< map<int,int>::iterator, bool > pr1, pr2;
pr1= m1.insert ( map <int, int> :: value_type ( 1, 10 ) );
pr2= m1.insert ( map <int, int> :: value_type ( 2, 5 ) );
if( vc1( *pr1.first, *pr2.first ) == true )
{ cout << "The element ( 1,10 ) precedes the element ( 2,5 )."<< endl; }
else
{ cout << "The element ( 1,10 ) does not precede the element ( 2,5 )."
<< endl;
}
if(vc1( *pr2.first, *pr1.first ) == true )
{ cout << "The element ( 2,5 ) precedes the element ( 1,10 )."<< endl; }
else
{ cout << "The element ( 2,5 ) does not precede the element ( 1,10 )."
<< endl; }
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?