Last active
August 29, 2015 14:13
-
-
Save yasuharu519/c7d7e11f97fc14247d13 to your computer and use it in GitHub Desktop.
algorithmヘッダを使ったfindの使用例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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