Skip to content

Instantly share code, notes, and snippets.

@YeyoM
Created February 22, 2023 15:30
Show Gist options
  • Save YeyoM/b13f45fccd598464fa9fdccc295fed13 to your computer and use it in GitHub Desktop.
Save YeyoM/b13f45fccd598464fa9fdccc295fed13 to your computer and use it in GitHub Desktop.
Búsqueda Secuencial implementado en cpp
// 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