From 2224c7016ff09a382d51d69c8fd525f5599397d3 Mon Sep 17 00:00:00 2001
From: Matheus Horstmann <horstmannmat@hotmail.com>
Date: Sat, 12 Dec 2015 14:51:44 -0200
Subject: [PATCH] log falta imprimir

Signed-off-by: Matheus Horstmann <horstmannmat@hotmail.com>
---
 Quadra.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/Quadra.c b/Quadra.c
index 221ee15..aefaccb 100644
--- a/Quadra.c
+++ b/Quadra.c
@@ -1,5 +1,6 @@
 #include "busca.h"
 #include <time.h>
+FILE *log;
 
 void vetSort(int *vet, int *vet_ord, int Tam, int max)
 {
@@ -17,7 +18,7 @@ void imprime (int *vet, int N)
     int i;
     for (i = 1; i <= N; i++)
     {
-        if ((i % 10) == 0)
+        if ((i % 10) == 1)
             printf ("\n\n");
         printf ("%d  ", vet[i]);
     }
@@ -27,18 +28,25 @@ void jogar (int *vet, int *vet_ord, int N)
 {
     int x, i = 0, j;
     printf ("Entre com a Quadra de valores: ");
+    fputs(" O usuario entrou com os seguintes valores : \[ ",log);
     for (j = 0; j < 4; j++)
     {
         scanf ("%d", &x);
+        fprintf(log,"%d, ", x);
+        fprintf(log
         if ((pesqseq(vet, x, N) != 0) || (pesqbin(vet_ord, x, N) != 0))
             i++;
     }
+    fputs("\]\n",log);
     if (i == 4)
         printf ("Sucesso!!\n");
+        fprintf(log,"Sucesso! Os numero inseridos estao contidos no vetor\n");
     else if (i > 0)
         printf ("%d valores encontrados!\n", i);
+        fprintf(log,"nem todos oss numero inseridos estao contidos no vetor\n");
     else
         printf ("Nenhum valor encontrado!\n");
+        fprintf (log,"Nenhum valor encontrado!\n");
 }
 
 void vetcpy (int *v1, int *v2, int N)
@@ -71,6 +79,7 @@ void jornada(int Tam, int max)
     tf = clock();
     tt = tempoEmMili(ti,tf);
     printf("SelectSort: %d micro-segundos\n", tt);
+    fprintf(log,"SelectSort: %d micro-segundos\n", tt);
 
     for (i = 0; i < 10000; i++)
         vetcpy(mat[i], mat_ord[i], Tam);
@@ -80,6 +89,7 @@ void jornada(int Tam, int max)
     tf = clock();
     tt = tempoEmMili(ti,tf);
     printf("BubbleSort: %d micro-segundos\n", tt);
+    fprintf(log,"BubbleSort: %d micro-segundos\n", tt);
 
     for (i = 0; i < 10000; i++)
         vetcpy(mat[i], mat_ord[i], Tam);
@@ -89,6 +99,7 @@ void jornada(int Tam, int max)
     tf = clock();
     tt = tempoEmMili(ti,tf);
     printf("QuickSort Recursivo: %d micro-segundos\n", tt);
+    fprintf(log,"QuickSort Recursivo: %d micro-segundos\n", tt);
 
     for (i = 0; i < 10000; i++)
         vetcpy(mat[i], mat_ord[i], Tam);
@@ -98,20 +109,29 @@ void jornada(int Tam, int max)
     tf = clock();
     tt = tempoEmMili(ti,tf);
     printf("QuickSort Iterativo: %d micro-segundos\n", tt);
+    fprintf(log,"QuickSort Iterativo: %d micro-segundos\n", tt);
 }
 
 int main (void)
 {
     int Tam, max, *vet, *vet_ord;
     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: ");
     scanf ("%d", &Tam);
+    fprintf(log, "O usuario escolheu um vetor de tamanho %d",Tam);
     printf ("Entre com valor maximo dos numeros aleatorios: ");
     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_ord = (int *) malloc ((Tam+1) * sizeof(int));
     vetSort(vet, vet_ord, Tam, max);
     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");
     menu = 1;
     while (menu != 0)
@@ -119,18 +139,25 @@ int main (void)
         switch (menu)
         {
         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");
             break;
         case 2:
+
+            fputs("O usuario escolheu a opcao 2, e foi exibido o vetor sorteado de numeros aleatorios");
             imprime (vet, Tam);
             break;
         case 3:
+            fputs("O usuario escolheu a opcao 3, e foi exibido o vetor sorteado de numeros aleatorios ordenado");
             imprime (vet_ord, Tam);
             break;
         case 4:
+            fputs("O usuario escolheu a opcao 4, e  comeca o jogo.");
             jogar (vet, vet_ord, Tam);
             break;
         case 5:
+            fputs("O usuario escolheu a opcao 5, e comeca a jorndada de 10.000 vetores");
             jornada(Tam, max);
             break;
         }
-- 
GitLab