From 8b866127047d5b503ab493678daba97376f654a0 Mon Sep 17 00:00:00 2001 From: madeleine4223 Date: Fri, 5 Aug 2016 15:06:27 -0400 Subject: [PATCH] started but didnt finish --- minesweeper.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 minesweeper.c diff --git a/minesweeper.c b/minesweeper.c new file mode 100644 index 0000000..ba91c38 --- /dev/null +++ b/minesweeper.c @@ -0,0 +1,47 @@ +/* Write a program minesweeper.c that takes in dimensions m and n from the user and a probability p, then generates a Minesweeper board of size m x n where each cell has a probability of p to be a mine (probability is a number between 0 and 1). Each cell that is not a mine contains a number representing how many mines (above, below, left, right, and diagonal) neighbor that "safe" cell. Print the board, representing each mine as an asterisk (*). + Your program should check for valid input. + Some tips: * You may want to store your board as an integer array, with some constant value for the mines (e.g. 99), then convert the integer representation to a * for printing*/ +#include +#include +#include +int main(){ + + int m; + int n; + printf("enter m(rows)\n"); + scanf("%d", &m); + printf("enter n(colums)\n"); + scanf("%d", &n); + char board[m] [n]; + int row=0; + int col=0; + srand(time(NULL)); + int x; + float p; + printf("Enter a probablity\n"); + scanf("%f", &p); + for (row=0;row