Essays.club - TCC, Modelos de monografias, Trabalhos de universidades, Ensaios, Bibliografias
Pesquisar

Redes uma abordagem top down

Por:   •  23/4/2018  •  1.130 Palavras (5 Páginas)  •  243 Visualizações

Página 1 de 5

...

de ordenação*/

int main()

{

/* Definição da variável de controle para atribuição dos valores aos vetores e criação dos vetores com tamanho máximo pré-definido */

int i;

int *vet1, *vet2, *vet3, *vet4;

vet1 = (int*) malloc(sizeof(int)*MAXTAM);

vet2 = (int*) malloc(sizeof(int)*MAXTAM);

vet3 = (int*) malloc(sizeof(int)*MAXTAM);

vet4 = (int*) malloc(sizeof(int)*MAXTAM);

/* Atribuição de Valores Aleatórios */

for (i=0; i<MAXTAM; i++)

{

vet1[i] = rand();

vet2[i] = vet1[i];

vet3[i] = vet1[i];

vet4[i] = vet1[i];

}

/* Teste do Método Bubble Sort */

time_t Ini_BubbleSort = time(NULL);

bubbleSort(vet1, MAXTAM);

time_t Fim_BubbleSort = time(NULL);

free(vet1);

/* Calculo e exibição do Tempo de execução */

printf("Tempo do BubbleSort em segundos: %f \n",difftime(Fim_BubbleSort,Ini_BubbleSort));

/* Fim do Método BubbleSort

--------------------------------------------------

/* Teste do Método Insertion Sort */

time_t Ini_InsertionSort = time(NULL);

insertionSort(vet2,MAXTAM);

time_t Fim_InsertionSort = time(NULL);

free(vet2);

/* Cálculo e exibição do tempo de execução */

printf("Tempo do InsertionSort em segundos: %f \n",difftime(Fim_InsertionSort,Ini_InsertionSort));

/* fim do Método Insertion Sort

--------------------------------------------------

Teste do Método Binary Insertion Sort */

time_t Ini_InsertionSortBin = time(NULL);

insertionSortBin(vet3,MAXTAM);

time_t Fim_InsertionSortBin = time(NULL);

free(vet3);

/* Cálculo e exibição do tempo de execução */

printf("Tempo do Binary Insertion Sort em segundos: %f \n",difftime(Fim_InsertionSortBin,Ini_InsertionSortBin));

/* Fim do Método Binary Insertion Sort

--------------------------------------------------

Teste do Método Shell Sort */

time_t Ini_ShellSort = time(NULL);

shellSort(vet4,MAXTAM);

time_t Fim_ShellSort = time(NULL);

free(vet4);

/* Cálculo e exibição do tempo de execução */

printf("Tempo do Shell Sort em segundos: %f \n",difftime(Fim_ShellSort,Ini_ShellSort));

/* Fim do Método Shell Sort*/

return 0;

}

...

Baixar como  txt (4.1 Kb)   pdf (45.6 Kb)   docx (12.9 Kb)  
Continuar por mais 4 páginas »
Disponível apenas no Essays.club