Created
February 22, 2023 15:30
-
-
Save YeyoM/b13f45fccd598464fa9fdccc295fed13 to your computer and use it in GitHub Desktop.
Búsqueda Secuencial implementado en cpp
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
// Diego Emilio Moreno Sánchez | |
#include <iostream> | |
using namespace std; | |
bool busquedaSecuencial(int arr[], int tam, int valor) { | |
for (int i = 0; i < tam; i++) { | |
if (arr[i] == valor) { | |
return true; | |
} | |
} | |
return false; | |
} | |
int main() { | |
int arr[] = {5, 2, 4, 6, 1, 3}; | |
int n = sizeof(arr) / sizeof(arr[0]); | |
bool encontrado = busquedaSecuencial(arr, n, 9); | |
cout << encontrado << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment