hope this helps
if you have any questions, shoot.. (my C is better than my English so, if i was unclear..)
Code:
#include <stdio.h>
#define MAX 12
#define FALSE 0
#define TRUE 1
void display();
void intialise();
void placeMine(int x1,int y1, char c);
int grid[MAX][MAX]; /* FALSE: no mine, TRUE: mine */
int visible[MAX][MAX]; /* true when 'clicked' */
int main(void)
{
printf("Welcome To Minesweeper \n");
int x,y; /* user coords.. */
intialise();
placeMine(11,11,'x'); /* this should become a minerandomiser */
printf("Enter 2 numbers: \n");
scanf("%d %d", &x, &y);
visible[x][y] = TRUE; /* 'clicked' on (x,y) */
if(grid[x][y]) /* if mine */
printf("Game Over\n");
else
display(); /* display grid */
system("PAUSE");
return 0;
}
void display()
{
int i, j;
printf("\n");
for (i = 0; i < MAX; i++) {
for (j = 0; j < MAX; j++)
if(!visible[i][j])
printf("0");
else if(grid[i][j]) /* if visible and mine */
printf("X");
else
printf("_");
/* write a function that calculates how many mines are next to mine[i][j], display this number (only when visible) */
printf("\n");
}
}
void intialise()
{
int i, j;
for (i = 0; i < 12; i++)
for (j = 0; j < 12; j++){
grid[i][j] = FALSE; /* you should write a function that randomises the mines,.. */
visible[i][j] = FALSE;
}
}
void placeMine(int x,int y, char c) /* this should become the randomise mine function */
{
grid[x][y] = TRUE; /* mine is placed on (x,y) */
}