#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int v[10] = {4,2,1,3,7,9,8,6,10,5};

void gerar_array(int v[10], int n){
    time_t t;

    srand((unsigned)&t);

    for (int i =0;i<n;i++){
        v[i] = rand()%10;
    }
}

void imprimir_array(int v[],int n){
    for (int i=0;i<n;i++){
        printf("%d ",v[i]);
    }
    printf("\n");
}

int buscar(int v[], int n, int x){
    int indice = -1;

    for (int i = 0;i<n;i++){
        if (v[i]==x){
            indice = i;
            break;
        }
    }

    return indice;
}

int main()
{
    int indice = -1;
    int x;
    char c;


    do{
        imprimir_array(v,10);
        printf("Digite um inteiro (1-10):\n");
        scanf("%d",&x);
        indice = buscar(v,10,x);

        if (indice>0){
            printf("A posicao do elemento %d eh %d\n",x, indice);
        }
        else{
            printf("Elemento nao encontrado\n");
        }
        printf("Continua (s/n)?\n");
        scanf(" %c",&c);

    } while (c =='s');

    return 0;
}

