?? chapter9-26.cpp
字號:
//文件名:CHAPTER9-26.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( )
{
multiset <int> ms1;
multiset <int> :: const_iterator ms1_AcIter, ms1_RcIter;
ms1.insert( 10 );
ms1.insert( 20 );
ms1.insert( 20 );
ms1_RcIter = ms1.find( 20 );
cout << "The first element of multiset ms1 with a key of 20 is: "<< *ms1_RcIter << "." << endl;
ms1_RcIter = ms1.find( 40 );
// 如果不存在, 將返回end( )
if ( ms1_RcIter == ms1.end( ) )
cout << "The multiset ms1 doesn't have an element "<< "with a key of 40." << endl;
else
cout << "The element of multiset ms1 with a key of 40 is: "<< *ms1_RcIter << "." << endl;
ms1_AcIter = ms1.end( );
ms1_AcIter--;
ms1_RcIter = ms1.find( *ms1_AcIter );
cout << "The first element of ms1 with a key matching" << endl
<< "that of the last element is: "<< *ms1_RcIter << "." << endl;
//返回第一個元素的迭代器
if ( ms1_RcIter == --ms1.end( ) ) cout << "This is the last element of multiset ms1." << endl;
else cout << "This is not the last element of multiset ms1." << endl;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -