#include <stdio.h>
void le_vetor(int v[], int n){
for(int i = 0; i < (n-1); i++){
scanf("%d\n", &v[i]);
}
}
int busca(int valores[], int n, int chave){
for(int i = 0; i < n; i++){
if(valores[i] == chave){
return i;
}
} return -1;
}
int main(){
int n, chave;
printf("Digite os valores de n e a chave\n");
scanf("%d %d", &n, &chave);
int v[n];
le_vetor(v, n);
printf("%d\n", busca(v, n, chave));
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: