list9-11.cpp
来自「这是关于VC++中的STL容器的资料,包括了STL容器各个类之间关系以及类的说明」· C++ 代码 · 共 31 行
CPP
31 行
// Listing 9.11
// Demonstrates binary_search() with a user defined object Clock.
#include <iostream>
#include <vector>
#include <algorithm>
#include <clktime.h>
//using namespace std;
void main(void)
{
vector<clock_time> List;
clock_time Clock(21,21);
List.push_back(clock_time(13,50));
List.push_back(clock_time(40,31));
List.push_back(clock_time(21,20));
List.push_back(clock_time(15,10));
sort(List.begin(),List.end());
if(binary_search(List.begin(),List.end(),Clock)){
cout << "Found It";
}
else{
cout << "No Hit";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?