📄 find_if.cpp
字号:
// find_if.cpp
// searches array of strings for first name that matches "Don"
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
//--------------------------------------------------------------
bool isDon(string name) // returns true if name=="Don"
{
return name == "Don";
}
//--------------------------------------------------------------
string names[] = { "George", "Estelle", "Don", "Mike", "Bob" };
int main()
{
string* ptr;
ptr = find_if( names, names+5, isDon );
if(ptr==names+5)
cout << "Don is not on the list.\n";
else
cout << "Don is element "
<< (ptr-names)
<< " on the list.\n";
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -