?? chapter9-25.cpp
字號(hào):
//文件名:CHAPTER9-25.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( )
{
set <int> s1;
set <int> :: const_iterator s1_AcIter, s1_RcIter;
s1.insert( 10 );
s1.insert( 20 );
s1.insert( 30 );
s1_RcIter = s1.find( 20 );
cout << "The element of set s1 with a key of 20 is: "<< *s1_RcIter << "." << endl;
s1_RcIter = s1.find( 40 );
// If no match is found for the key, end( ) is returned
if ( s1_RcIter == s1.end( ) )
cout << "The set s1 doesn't have an element "<< "with a key of 40." << endl;
else
cout << "The element of set s1 with a key of 40 is: "<< *s1_RcIter << "." << endl;
// The element at a specific location in the set can be found
// by using a dereferenced iterator addressing the location
s1_AcIter = s1.end( );
s1_AcIter--;
s1_RcIter = s1.find( *s1_AcIter );
cout << "The element of s1 with a key matching "<< "that of the last element is: "
<< *s1_RcIter << "." << endl;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -