Skip to content
Snippets Groups Projects
Commit 2224c701 authored by Matheus Horstmann's avatar Matheus Horstmann
Browse files

log falta imprimir

parent e4de54b7
Branches
No related tags found
No related merge requests found
#include "busca.h" #include "busca.h"
#include <time.h> #include <time.h>
FILE *log;
void vetSort(int *vet, int *vet_ord, int Tam, int max) void vetSort(int *vet, int *vet_ord, int Tam, int max)
{ {
...@@ -17,7 +18,7 @@ void imprime (int *vet, int N) ...@@ -17,7 +18,7 @@ void imprime (int *vet, int N)
int i; int i;
for (i = 1; i <= N; i++) for (i = 1; i <= N; i++)
{ {
if ((i % 10) == 0) if ((i % 10) == 1)
printf ("\n\n"); printf ("\n\n");
printf ("%d ", vet[i]); printf ("%d ", vet[i]);
} }
...@@ -27,18 +28,25 @@ void jogar (int *vet, int *vet_ord, int N) ...@@ -27,18 +28,25 @@ void jogar (int *vet, int *vet_ord, int N)
{ {
int x, i = 0, j; int x, i = 0, j;
printf ("Entre com a Quadra de valores: "); printf ("Entre com a Quadra de valores: ");
fputs(" O usuario entrou com os seguintes valores : \[ ",log);
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
scanf ("%d", &x); scanf ("%d", &x);
fprintf(log,"%d, ", x);
fprintf(log
if ((pesqseq(vet, x, N) != 0) || (pesqbin(vet_ord, x, N) != 0)) if ((pesqseq(vet, x, N) != 0) || (pesqbin(vet_ord, x, N) != 0))
i++; i++;
} }
fputs("\]\n",log);
if (i == 4) if (i == 4)
printf ("Sucesso!!\n"); printf ("Sucesso!!\n");
fprintf(log,"Sucesso! Os numero inseridos estao contidos no vetor\n");
else if (i > 0) else if (i > 0)
printf ("%d valores encontrados!\n", i); printf ("%d valores encontrados!\n", i);
fprintf(log,"nem todos oss numero inseridos estao contidos no vetor\n");
else else
printf ("Nenhum valor encontrado!\n"); printf ("Nenhum valor encontrado!\n");
fprintf (log,"Nenhum valor encontrado!\n");
} }
void vetcpy (int *v1, int *v2, int N) void vetcpy (int *v1, int *v2, int N)
...@@ -71,6 +79,7 @@ void jornada(int Tam, int max) ...@@ -71,6 +79,7 @@ void jornada(int Tam, int max)
tf = clock(); tf = clock();
tt = tempoEmMili(ti,tf); tt = tempoEmMili(ti,tf);
printf("SelectSort: %d micro-segundos\n", tt); printf("SelectSort: %d micro-segundos\n", tt);
fprintf(log,"SelectSort: %d micro-segundos\n", tt);
for (i = 0; i < 10000; i++) for (i = 0; i < 10000; i++)
vetcpy(mat[i], mat_ord[i], Tam); vetcpy(mat[i], mat_ord[i], Tam);
...@@ -80,6 +89,7 @@ void jornada(int Tam, int max) ...@@ -80,6 +89,7 @@ void jornada(int Tam, int max)
tf = clock(); tf = clock();
tt = tempoEmMili(ti,tf); tt = tempoEmMili(ti,tf);
printf("BubbleSort: %d micro-segundos\n", tt); printf("BubbleSort: %d micro-segundos\n", tt);
fprintf(log,"BubbleSort: %d micro-segundos\n", tt);
for (i = 0; i < 10000; i++) for (i = 0; i < 10000; i++)
vetcpy(mat[i], mat_ord[i], Tam); vetcpy(mat[i], mat_ord[i], Tam);
...@@ -89,6 +99,7 @@ void jornada(int Tam, int max) ...@@ -89,6 +99,7 @@ void jornada(int Tam, int max)
tf = clock(); tf = clock();
tt = tempoEmMili(ti,tf); tt = tempoEmMili(ti,tf);
printf("QuickSort Recursivo: %d micro-segundos\n", tt); printf("QuickSort Recursivo: %d micro-segundos\n", tt);
fprintf(log,"QuickSort Recursivo: %d micro-segundos\n", tt);
for (i = 0; i < 10000; i++) for (i = 0; i < 10000; i++)
vetcpy(mat[i], mat_ord[i], Tam); vetcpy(mat[i], mat_ord[i], Tam);
...@@ -98,20 +109,29 @@ void jornada(int Tam, int max) ...@@ -98,20 +109,29 @@ void jornada(int Tam, int max)
tf = clock(); tf = clock();
tt = tempoEmMili(ti,tf); tt = tempoEmMili(ti,tf);
printf("QuickSort Iterativo: %d micro-segundos\n", tt); printf("QuickSort Iterativo: %d micro-segundos\n", tt);
fprintf(log,"QuickSort Iterativo: %d micro-segundos\n", tt);
} }
int main (void) int main (void)
{ {
int Tam, max, *vet, *vet_ord; int Tam, max, *vet, *vet_ord;
int menu; int menu;
log = fopen("log.txt","w");
fputs( "=================================================================================\n
Inicio da execucao: programa que implementa as especificacoes do trabalho 2.\n
Cristopher Luis Mattoso, Matheus Horstmann\n
==================================================================================\n",log)/
printf ("Entre com tamanho de vetor: "); printf ("Entre com tamanho de vetor: ");
scanf ("%d", &Tam); scanf ("%d", &Tam);
fprintf(log, "O usuario escolheu um vetor de tamanho %d",Tam);
printf ("Entre com valor maximo dos numeros aleatorios: "); printf ("Entre com valor maximo dos numeros aleatorios: ");
scanf ("%d", &max); scanf ("%d", &max);
fprintf(log, "O usuario escolheu valor maximo que o vetor pode ter, esse valor eh : %d",max);
vet = (int *) malloc ((Tam+1) * sizeof(int)); vet = (int *) malloc ((Tam+1) * sizeof(int));
vet_ord = (int *) malloc ((Tam+1) * sizeof(int)); vet_ord = (int *) malloc ((Tam+1) * sizeof(int));
vetSort(vet, vet_ord, Tam, max); vetSort(vet, vet_ord, Tam, max);
QuickSort_it(vet_ord, Tam); QuickSort_it(vet_ord, Tam);
fprintf(log,"Foi alocado 2 vetores de tamanho %d com o valor maximo de %d, com os numeros sorteados, sendo um deles já ordenado",Tam,max);
printf ("\nMenu:\n"); printf ("\nMenu:\n");
menu = 1; menu = 1;
while (menu != 0) while (menu != 0)
...@@ -119,18 +139,25 @@ int main (void) ...@@ -119,18 +139,25 @@ int main (void)
switch (menu) switch (menu)
{ {
case 1: case 1:
fputs("O usuario escolheu a opcao 1, e foi exibido o menu, onde:\n 1 - Mostra o menu\n2 - Imprime Vetor de Numeros Aleatorios\n3 - Imprime Vetor Ordenado\n4 - Joga a Quadra \n5 - Faz a jornada dos 10.000 vetores\n0 - Sai\n",log);
printf ("1 - Mostrar menu\n2 - Imprimir Vetor de Numeros Aleatorios\n3 - Imprimir Vetor Ordenado\n4 - Jogar\n5 - Fazer jornada dos 10.000 vetores\n0 - Sair\n"); printf ("1 - Mostrar menu\n2 - Imprimir Vetor de Numeros Aleatorios\n3 - Imprimir Vetor Ordenado\n4 - Jogar\n5 - Fazer jornada dos 10.000 vetores\n0 - Sair\n");
break; break;
case 2: case 2:
fputs("O usuario escolheu a opcao 2, e foi exibido o vetor sorteado de numeros aleatorios");
imprime (vet, Tam); imprime (vet, Tam);
break; break;
case 3: case 3:
fputs("O usuario escolheu a opcao 3, e foi exibido o vetor sorteado de numeros aleatorios ordenado");
imprime (vet_ord, Tam); imprime (vet_ord, Tam);
break; break;
case 4: case 4:
fputs("O usuario escolheu a opcao 4, e comeca o jogo.");
jogar (vet, vet_ord, Tam); jogar (vet, vet_ord, Tam);
break; break;
case 5: case 5:
fputs("O usuario escolheu a opcao 5, e comeca a jorndada de 10.000 vetores");
jornada(Tam, max); jornada(Tam, max);
break; break;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment