When doing the cycles so that the matrix generates me, it arrives the point in which when having to generate the matrix it remains motionless, and it does not happen of there. The code is for a "game", inside the code come the instructions. I have already done all the code and if it compiles and executes, but it does not generate the matrix after giving the instructions What did I do wrong?
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
#include <wchar.h>
#include <locale.h>
#include <time.h>
#include <string.h>
main()
{
system("cls");
setlocale(LC_ALL, "");
int Matriz[4][4], Contador1, Contador2, x, y, TomJerryEncontrados, c1, PuntajeJugador1, PuntajeJugador2;
PuntajeJugador1=0;
PuntajeJugador2=0;
TomJerryEncontrados=0;
char c2[10];
bool V1, V2, V3;
V1=false;
V2=false;
V3=true;
char NombreJugador1[30], NombreJugador2[30];
printf("Introduce el nombre del jugador 1:\n");
fflush(stdin);
scanf("%s", &NombreJugador1);
printf("Introduce el nombre del jugador 2:\n");
fflush(stdin);
scanf("%s", &NombreJugador2);
system("cls");
printf("Hola %s y %s ! Bienvenidos al juego Tom y Jerry\n", NombreJugador1, NombreJugador2);
printf("Las intrucciones del juego son las siguientes:\n\n");
printf("%s será Tom y %s será Jerry\n", NombreJugador1, NombreJugador2);
printf("La matriz tendrá escondidas 3 palabras -Tom- y 3 palabras -Jerry- más aparte una palabra -Queso- y otra -Captura-\n");
printf("Para encontrar las palabras cada jugador debe dar un número de casilla por turnos\n");
printf("El juego termina cuando todas las casillas estén abiertas\n");
printf("El ganador será quién acumule más puntos\n");
printf("Al encontrar la palabra -Tom- serán 10 puntos para Tom y menos 10 puntos para Jerry\n");
printf("Al encontrar la palabra -Jerry- serán 10 puntos para Jerry y menos 10 puntos para Tom\n");
printf("Si Tom encuentra la palabra -Captura- ganará 50 puntos y finalizará el juego\n");
printf("Si Jerry encuentra la palabra -Queso- ganará 50 puntos y finalizará el juego\n");
printf("Si Tom encuentra la palabra -Queso- perderá 10 puntos\n");
printf("Si Jerry encuentra la palabra -Captura- perderá 10 puntos\n");
printf("Si la casilla está vacía los dos perderán 5 puntos\n");
system("PAUSE");
//printf("Cargando...");
Contador1=0;
while(Contador1<4)
{
while(Contador2<4)
{
Matriz[Contador1][Contador2]=0;
Contador2++;
}
Contador1++;
}
Contador1=0;
while(Contador1<3)
{
srand((unsigned)time(NULL));
c1=rand()%16;
y=c1/4;
x=c1-(4*y);
if (Matriz[x][y]==0)
{
Matriz[x][y]=1; // 3 Tom
Contador1++;
}
}
Contador1=0;
while(Contador1<3)
{
srand((unsigned)time(NULL));
c1=rand()%16;
y=c1/4;
x=c1-(4*y);
if (Matriz[x][y]==0)
{
Matriz[x][y]=2; // 3 Jerry
Contador1++;
}
}
Contador1=0;
while(Contador1<1)
{
srand((unsigned)time(NULL));
c1=rand()%16;
y=c1/4;
x=c1-(4*y);
if (Matriz[x][y]==0)
{
Matriz[x][y]=3; // 1 Queso
Contador1++;
}
}
Contador1=0;
while(Contador1<1)
{
srand((unsigned)time(NULL));
c1=rand()%16;
y=c1/4;
x=c1-(4*y);
if (Matriz[x][y]==0)
{
Matriz[x][y]=4; // 1 Captura
Contador1++;
}
}
system("cls");
while (TomJerryEncontrados<6)
{
printf("Puntaje de %s = %d || Puntaje de %s = %d \n", NombreJugador1, PuntajeJugador1, NombreJugador2, PuntajeJugador2);
if (V1==false)
{
if (V2==true)
{
printf("La casilla ya fue seleccionada anteriormente\n\n");
V2==false;
}
else
{
if (V3==false)
{
printf("El número de casilla no es válido\n\n");
V3=true;
}
else
{
printf("Es turno de %s\n\n", NombreJugador1);
}
}
}
else
{
if (V2==true)
{
printf("La casilla ya fue seleccionada anteriormente\n\n");
V2=false;
}
else
{
if (V3==false)
{
printf("El número de casilla no es válido\n\n");
V3=true;
}
else
{
printf("Es turno de %s\n\n", NombreJugador2);
}
}
}
Contador1=0;
while (Contador1<4)
{
Contador2=0;
while (Contador2<4)
{
switch (Matriz[Contador2][Contador1])
{
case 0:
printf("%d\t", (4*Contador1)+Contador2+1);
break;
case 1:
printf("%d\t", (4*Contador1)+Contador2+1);
break;
case 2:
printf("%d\t", (4*Contador1)+Contador2+1);
break;
case 3:
printf("%d\t", (4*Contador1)+Contador2+1);
break;
case 4:
printf("Vacío\t");
break;
case 5:
printf("Tom\t");
break;
case 6:
printf("Jerry\t");
break;
case 7:
printf("Queso\t");
break;
case 8:
printf("Captura\t");
break;
}
Contador2++;
}
printf("\n");
Contador1++;
}
printf("Selecciona el número de una casilla\n");
scanf("%s", &c2);
int c1=atoi(c2);
c1=c1-1;
if (c1>=0 && c1<=15)
{
y=c1/4;
x=c1-(4*y);
switch (Matriz[x][y])
{
case 0:
Matriz[x][y]=4;
if (V1==true)
{
PuntajeJugador2=PuntajeJugador2-5;
V1=false;
}
else
{
PuntajeJugador1=PuntajeJugador1-5;
V1=true;
}
break;
case 1:
Matriz[x][y]=5;
TomJerryEncontrados++;
if (V1==true)
{
PuntajeJugador2=PuntajeJugador2-10;
V1=false;
}
else
{
PuntajeJugador1=PuntajeJugador1+10;
V1=true;
}
break;
case 2:
Matriz[x][y]=6;
if (V1==true)
{
TomJerryEncontrados++;
PuntajeJugador2=PuntajeJugador2+10;
V1=false;
}
else
{
PuntajeJugador1=PuntajeJugador1-10;
V1=true;
}
break;
case 3:
Matriz[x][y]=7;
TomJerryEncontrados=7;
if (V1==true)
{
PuntajeJugador2=PuntajeJugador2+50;
}
else
{
PuntajeJugador1=PuntajeJugador1-50;
}
break;
case 4:
Matriz[x][y]=8;
TomJerryEncontrados=8;
if (V1==true)
{
PuntajeJugador2=PuntajeJugador2-50;
}
else
{
PuntajeJugador1=PuntajeJugador1+50;
}
default:
V2=true;
break;
}
}
else
{
V3=false;
}
system("cls");
}
system("cls");
if(TomJerryEncontrados==6)
{
printf("Encontraron todos los Tom y Jerry disponibles\n");
}
else
{
printf("Fin del juego\n");
}
if(PuntajeJugador1>PuntajeJugador2)
{
printf("El ganador es %s\n", NombreJugador1);
}
else
{
printf("El ganador es %s\n", NombreJugador2);
}
getch();
}