diff --git a/Arquivos/Estruturas.h b/Arquivos/Estruturas.h index c040942d4b1c12566c7c978cae3a421e861feabb..f77b55dec388dcf6560ea5074ca42e53daccea5a 100644 --- a/Arquivos/Estruturas.h +++ b/Arquivos/Estruturas.h @@ -1,3 +1,6 @@ //Arquivo que contém os defines e os registros -#define TAM 20 //tamanho do vetor -#define MAX 50 //constante que tem o máximo de valores +#include <stdio.h> +#include <time.h> +#include <stdlib.h> +#define TAM 15 //tamanho do vetor +#define NUMMAX 50 //constante que tem o máximo de valores diff --git a/Arquivos/Loteria b/Arquivos/Loteria new file mode 100755 index 0000000000000000000000000000000000000000..b52911213aedbde8b1ac3673e0efb962f1f54eff Binary files /dev/null and b/Arquivos/Loteria differ diff --git a/Arquivos/Main.c b/Arquivos/Main.c new file mode 100644 index 0000000000000000000000000000000000000000..f481f2cdfe7d8578b6951a50207cf6b49f8d0564 --- /dev/null +++ b/Arquivos/Main.c @@ -0,0 +1,10 @@ +#include "Estruturas.h" + +int main () { + int Vetor[TAM]; + + GeraVetor(Vetor); + ImprimeVetor(Vetor); + SelectSort (Vetor); + ImprimeVetor (Vetor); +} diff --git a/Arquivos/Menu.c b/Arquivos/Menu.c deleted file mode 100644 index 22070d935fbd77afa8651151c40baf51fd5dd542..0000000000000000000000000000000000000000 --- a/Arquivos/Menu.c +++ /dev/null @@ -1 +0,0 @@ -//Aqui a main do trabalho diff --git "a/Arquivos/Ordena\303\247\303\243o.c" "b/Arquivos/Ordena\303\247\303\243o.c" index 25149fae4cecad21350fcdaef2df5f17ce150996..9e34a51a81c649123819cda3d647161c53e1a8aa 100644 --- "a/Arquivos/Ordena\303\247\303\243o.c" +++ "b/Arquivos/Ordena\303\247\303\243o.c" @@ -1 +1,23 @@ -//Arquivo que ira conter os Algoritmos de ordenação +//Arquivo com os Algoritmos de Ordenação + +#include "Estruturas.h" + +void Troca (int *Vetor, int i, int j) { + int aux; + + aux = Vetor[i]; + Vetor [i] = Vetor[j]; + Vetor [j] = aux; +} + +void SelectSort (int *Vetor) { + int i, j, menor; + + for (i = 0; i < TAM - 1; i++) { + menor = i; + for (j = i + 1; j < TAM; j++) + if (Vetor[menor] > Vetor[j]) + menor = j; + Troca (Vetor, i, menor); + } +} diff --git a/Arquivos/Pesquisa.c b/Arquivos/Pesquisa.c index 5dc88631e0981a787a133e57595f936b0fd475b0..f82e802206b8cc76746bdda12c347bdb250623bc 100644 --- a/Arquivos/Pesquisa.c +++ b/Arquivos/Pesquisa.c @@ -1 +1 @@ -//Vai contém os algoritmos de busca +//Arquivo com os algoritmos de busca diff --git a/Arquivos/Vetor.c b/Arquivos/Vetor.c index ef5817479d46c73002c6553e4bd52b826ee32ad0..16400e3a8f34fc59d183fe477484ee9372be3134 100644 --- a/Arquivos/Vetor.c +++ b/Arquivos/Vetor.c @@ -1 +1,24 @@ -//Funções do vetor +#include "Estruturas.h" + +//Função que gera valores aleatorios para o vetor +void GeraVetor (int *Vetor) { + int i; + + srand (time(NULL)); + for (i=0; i < TAM; i++) + Vetor[i] = rand () % NUMMAX; +} + +//Função que imprime o vetor +void ImprimeVetor (int *Vetor) { + int i; + + printf ("Pos: "); + for (i=0; i < TAM; i++) + printf ("\t%d", i); + printf ("\n"); + printf ("Num: "); + for (i=0; i < TAM; i++) + printf ("\t%d", Vetor[i]); + printf ("\n"); +} diff --git a/Arquivos/makefile b/Arquivos/makefile new file mode 100644 index 0000000000000000000000000000000000000000..430b929f1e6d5d35ca54d1ddc1d1a7e399d47dd6 --- /dev/null +++ b/Arquivos/makefile @@ -0,0 +1,8 @@ +all: + gcc -c Vetor.c + gcc -c Ordenação.c + gcc -c Pesquisa.c + gcc -c Main.c + gcc Vetor.o Ordenação.o Main.o Pesquisa.o -o Loteria -g + rm *.o +