📄 chapter6-15.cpp
字号:
//文件名:].cpp
#pragma warning(disable:4786)
#include <string>
#include <vector>
#include <algorithm>
#include <iostream.h>
using namespace std;
class EventIsIn1997
{public:
bool operator () (string& EventRecord)
{return EventRecord.substr(12,4)=="1997";}
};
void main (void)
{
vector<string> Events;
Events.push_back("07 January 1995 Draft plan of house prepared");
Events.push_back("07 February 1996 Detailed plan of house prepared");
Events.push_back("10 January 1997 Client agrees to job");
Events.push_back("15 January 1997 Builder starts work on bedroom");
Events.push_back("30 April 1997 Builder finishes work");
vector<string>::iterator EventIterator =find_if (Events.begin(), Events.end(), EventIsIn1997());
if (EventIterator==Events.end()) { cout << "Event not found in vector" << endl; }
else {cout << "Event found in vector" << endl; }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -