Using a two-dimensional array, create a program to implement a minefield game. To fill the array positions, use random numbers so that 0 represents a free position and 1 a pump. The user must be able to commit 3 errors. Free chosen positions should be marked by (ASCII 2); positions with pumps already chosen must be marked (ASCII 15) and unmarked positions should be marked with (ASCII 63).
How do I hide the positions of the houses with the figures (ASCII 2)?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define tam 10
int matri[tam][tam];
void forma()
{
int i, e;
for(i=0; i<10; i++)
{
for(e=0; e<10; e++)
{
matri[e][i]= rand()%2;
}
}
}
void mostra()
{
int i, e;
for(i=0; i<10; i++)
{
for(e=0; e<10; e++)
{
printf("%3d",matri[e][i]);
}
printf("\n");
}
}
//
void jogar()
{
int L,C, erros=0;
char a = 2, b = 15;
do
{
printf("\n\n linha L ?");
scanf("%d", &L);
printf("\n\n coluna C ?");
scanf("%d", &C);
if(matri[L][C] = 0)
{
matri[L][C] = a;
}
else if(matri[L][C] = 1)
{
erros++;
matri[L][C] = b;
}
}
while(erros = 3);
}
int main(int argc, char *argv[])
{
forma();
mostra();
esconde();
jogar();
return 0;
}