Skip to content

Instantly share code, notes, and snippets.

@yasuharu519
Last active August 29, 2015 14:13
Show Gist options
  • Save yasuharu519/c7d7e11f97fc14247d13 to your computer and use it in GitHub Desktop.
Save yasuharu519/c7d7e11f97fc14247d13 to your computer and use it in GitHub Desktop.
algorithmヘッダを使ったfindの使用例
#include <iostream>
#include <vector>
int main()
{
std::vector<int> v{1, 2, 3, 4, 5, 6};
int target = 5;
auto it = std::find(v.begin(), v.end(), target);
bool flag = it != v.end();
std::cout << "target " << target << " is " << (flag ? "found" : "not found")
<< std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment