Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 11, 2020 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/d9dc9636198ac265feaa54a9769c83a5 to your computer and use it in GitHub Desktop.
Save parzibyte/d9dc9636198ac265feaa54a9769c83a5 to your computer and use it in GitHub Desktop.
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
/*
https://parzibyte.me/blog
*/
bool existeEnVector(vector<string> v, string busqueda) {
return find(v.begin(), v.end(), busqueda) != v.end();
}
int main() {
vector<string> nombres;
nombres.push_back("Luis");
nombres.push_back("Pedro");
nombres.push_back("José");
if (existeEnVector(nombres, "Luis")) {
cout << "Sí existe";
} else {
cout << "No existe";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment