⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chapter9-27.cpp

📁 C++STL程序员开发指南
💻 CPP
字号:
//文件名:CHAPTER9-27.cpp
#include <set>
#include <iostream>
#if _MSC_VER > 1020   // if VC++ version is > 4.2
   using namespace std;  // std c++ libs implemented in std
#endif
int main( )
{
   typedef set<int, less< int > > IntSet;
   IntSet s1;
   set <int, less< int > > :: const_iterator s1_RcIter;
   s1.insert( 10 );
   s1.insert( 20 );
   s1.insert( 30 );
   pair <IntSet::const_iterator, IntSet::const_iterator> p1, p2;
   p1 = s1.equal_range( 20 );
   cout << "The upper bound of the element with "
        << "a key of 20 in the set s1 is: "<< *(p1.second) << "." << endl;
   cout << "The lower bound of the element with "
        << "a key of 20 in the set s1 is: "<< *(p1.first) << "." << endl;
   // If no match is found for the key, both elements of the pair return end( )
   if ( ( p2.first == s1.end( ) ) && ( p2.second == s1.end( ) ) )
      cout << "The set s1 doesn't have an element "<< "with a key less than 40." << endl;
   else
      cout << "The element of set s1 with a key >= 40 is: "<< *(p1.first) << "." << endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -