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

erro no jogo

parent 9affe5a6
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)
{ {
...@@ -14,7 +13,7 @@ void vetSort(int *vet, int *vet_ord, int Tam, int max) ...@@ -14,7 +13,7 @@ void vetSort(int *vet, int *vet_ord, int Tam, int max)
} }
} }
void imprime (int *vet, int N) void imprime (int *vet, int N,FILE *log)
{ {
int i; int i;
for (i = 1; i <= N; i++) for (i = 1; i <= N; i++)
...@@ -25,9 +24,9 @@ void imprime (int *vet, int N) ...@@ -25,9 +24,9 @@ void imprime (int *vet, int N)
} }
} }
void jogar (int *vet, int *vet_ord, int N) void jogar (int *vet, int *vet_ord, int N,FILE *log)
{ {
int x, i = 0, j; int x, i = 0, j, vetor[4];
printf ("Entre com a Quadra de valores: "); printf ("Entre com a Quadra de valores: ");
fprintf(log, " O usuario entrou com os seguintes valores : ["); fprintf(log, " O usuario entrou com os seguintes valores : [");
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
...@@ -35,16 +34,19 @@ void jogar (int *vet, int *vet_ord, int N) ...@@ -35,16 +34,19 @@ void jogar (int *vet, int *vet_ord, int N)
scanf ("%d", &x); scanf ("%d", &x);
fprintf(log,"%d, ", x); fprintf(log,"%d, ", x);
if ((pesqseq(vet, x, N) != 0) || (pesqbin(vet_ord, x, N) != 0)) if ((pesqseq(vet, x, N) != 0) || (pesqbin(vet_ord, x, N) != 0))
vetor[i]=x;
i++; i++;
} }
scanf ("%d", &x); scanf ("%d", &x);
fprintf(log, "%d]\n",x); fprintf(log, "%d]\n",x);
if ((pesqseq(vet, x, N) != 0) || (pesqbin(vet_ord, x, N) != 0)) if ((pesqseq(vet, x, N) != 0) || (pesqbin(vet_ord, x, N) != 0))
vetor[3]=x;
i++; i++;
if (i == 4) if (i == 4)
{ {
printf ("Sucesso!!\n"); printf ("Sucesso!! [%d %d %d %d]\n", vetor[0], vetor[1], vetor [2], vetor [3] );
fprintf(log,"Sucesso! Os numero inseridos estao contidos no vetor\n"); fprintf(log,"Sucesso! Os numero inseridos estao contidos no vetor: [%d %d %d %d]\n", vetor[0], vetor[1], vetor [2], vetor [3] );
} }
else if (i > 1) else if (i > 1)
{ {
...@@ -77,7 +79,7 @@ int tempoEmMic(clock_t inicio, clock_t fim) ...@@ -77,7 +79,7 @@ int tempoEmMic(clock_t inicio, clock_t fim)
return tt; return tt;
} }
void jornada(int Tam, int max) void jornada(int Tam, int max, FILE *log)
{ {
clock_t ti, tf; clock_t ti, tf;
int i, *mat[10000], *mat_ord[10000], tt; int i, *mat[10000], *mat_ord[10000], tt;
...@@ -128,24 +130,25 @@ void jornada(int Tam, int max) ...@@ -128,24 +130,25 @@ void jornada(int Tam, int max)
int main (void) int main (void)
{ {
FILE *log;
int Tam, max, *vet, *vet_ord; int Tam, max, *vet, *vet_ord;
int menu; int menu;
log = fopen("log.txt","w"); log = fopen("log.txt","w");
fputs(" =================================================================================\n fputs("==================================================================================\n",log);
Inicio da execucao: programa que implementa as especificacoes do trabalho 2.\n fputs(" Inicio da execucao: programa que implementa as especificacoes do trabalho 2.\n",log);
Cristopher Luis Mattoso, Matheus Horstmann\n fputs(" Cristopher Luis Mattoso, Matheus Horstmann\n",log);
==================================================================================\n",log)/ fputs("===================================================================================\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); fprintf(log, "O usuario escolheu um vetor de tamanho %d\n",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); fprintf(log, "O usuario escolheu valor maximo que o vetor pode ter, esse valor eh : %d\n",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); fprintf(log,"Foi alocado 2 vetores de tamanho %d com o valor maximo de %d, com os numeros sorteados, sendo um deles já ordenado\n",Tam,max);
printf ("\nMenu:\n"); printf ("\nMenu:\n");
menu = 1; menu = 1;
while (menu != 0) while (menu != 0)
...@@ -159,20 +162,20 @@ int main (void) ...@@ -159,20 +162,20 @@ int main (void)
break; break;
case 2: case 2:
fputs("O usuario escolheu a opcao 2, e foi exibido o vetor sorteado de numeros aleatorios",log); fputs("O usuario escolheu a opcao 2, e foi exibido o vetor sorteado de numeros aleatorios\n",log);
imprime (vet, Tam); imprime (vet, Tam,log);
break; break;
case 3: case 3:
fputs("O usuario escolheu a opcao 3, e foi exibido o vetor sorteado de numeros aleatorios ordenado",log); fputs("O usuario escolheu a opcao 3, e foi exibido o vetor sorteado de numeros aleatorios ordenado\n",log);
imprime (vet_ord, Tam); imprime (vet_ord, Tam, log);
break; break;
case 4: case 4:
fputs("O usuario escolheu a opcao 4, e comeca o jogo.",log); fputs("O usuario escolheu a opcao 4, e comeca o jogo.\n",log);
jogar (vet, vet_ord, Tam); jogar (vet, vet_ord, Tam, log);
break; break;
case 5: case 5:
fputs("O usuario escolheu a opcao 5, e comeca a jorndada de 10.000 vetores",log); fputs("O usuario escolheu a opcao 5, e comeca a jorndada de 10.000 vetores\n",log);
jornada(Tam, max); jornada(Tam, max, log);
break; break;
} }
printf ("\nNova Entrada: "); printf ("\nNova Entrada: ");
......
No preview for this file type
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.Quadra.exe</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
File added
No preview for this file type
log.txt 0 → 100644
==================================================================================
Inicio da execucao: programa que implementa as especificacoes do trabalho 2.
Cristopher Luis Mattoso, Matheus Horstmann
===================================================================================
O usuario escolheu um vetor de tamanho 1000
O usuario escolheu valor maximo que o vetor pode ter, esse valor eh : 10000
Foi alocado 2 vetores de tamanho 1000 com o valor maximo de 10000, com os numeros sorteados, sendo um deles já ordenado
O usuario escolheu a opcao 1, e foi exibido o menu, onde:
1 - Mostra o menu
2 - Imprime Vetor de Numeros Aleatorios
3 - Imprime Vetor Ordenado
4 - Joga a Quadra
5 - Faz a jornada dos 10.000 vetores
0 - Sai
O usuario escolheu a opcao 4, e comeca o jogo.
O usuario entrou com os seguintes valores : [100, 200, 300, 400]
Sucesso! Os numero inseridos estao contidos no vetor: [1572100480 32767 1 0]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment