You are on page 1of 1

#include "iostream"

using namespace std;

void tamao(int);
int buscar(int[], int, int);

void main() {
int vector[99], n, num, posicion;
tamao(n);
cout << "Buscar elemento: ";cin >> num;

buscar(vector, n, num);
system("pause");
}

void tamao(int n) {
do {
cout << "Ingrese tamao: ";cin >> n;
} while (n > 0);
}

int buscar(int v[99], int n, int x) {


for (int i = 0; i < n; i++) {
if (v[i] == x) return i;
else {
cout << "Elemento no encontrado." << endl;
return 0;
}
}
}

You might also like