-
-
Save parzibyte/68e9d38304a1f0831a5e7d7a71231bd7 to your computer and use it in GitHub Desktop.
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
std::string nombres[] = { | |
"Luis", "Marijo", "Paco", "Pedro", | |
}; | |
std::string busqueda = "Luis"; | |
int indice = -1; | |
for (int i = 0; i < sizeof(nombres) / sizeof(nombres[0]); i++) { | |
std::string nombreActual = nombres[i]; | |
if (nombreActual == busqueda) { | |
indice = i; | |
break; | |
} | |
} | |
if (indice == -1) { | |
std::cout << "No encontrado\n"; | |
} else { | |
std::cout << "Encontrado en el indice " << indice << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment