From e32ac312cd8fcf513c9a7a4a520227160be95d3c Mon Sep 17 00:00:00 2001 From: Gabriel Ruschel <grc15@inf.ufpr.br> Date: Sun, 29 Nov 2015 00:20:31 -0200 Subject: [PATCH] Pesquisa sequencial --- Arquivos/Pesquisa.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Arquivos/Pesquisa.c b/Arquivos/Pesquisa.c index 26e25dd..740af53 100644 --- a/Arquivos/Pesquisa.c +++ b/Arquivos/Pesquisa.c @@ -20,6 +20,15 @@ int PesquisaBinaria (int *Vetor, int Elem) { return -1; //return = -1 pq o se o elemento estiver na primeira posição irá retornar 0 (posição que ele se encontra no vetor) } +int PesquisaSequencial(int *Vetor, int Elem) { + int i; + Vetor[0] = Elem; + for (i=TAM-1; i>=0; i++) { + if (Vetor[i] == Elem) + return i; + } +} + void VerificaNumero (int *Vetor, int *Escolhidos) { int i, acertos; -- GitLab