Mine game program documentation
Pre-defined:
# DefineMAX_X 100//Maximum coordinate of rows
# Define# MAX_Y 100//Maximum ordinate Value
Global Array:
CharMap [MAX_X] [MAX_Y];
//It is a coordinate array that stores the distribution of mines.
IntM, n;
//It is the coordinate size (used for Level Selection)
//Note: differences between MAX_X, MAX_Y, and m and n
Algorithm function interface:
1Returns the number of surrounding mines.
/***************************************** ***********************************
Returns the number of surrounding mines.
Function prototype: int round_num_mines (int I, int j );
Parameter: int I, int j is the current Coordinate
Return Value Type: int, which returns the number of mines around the coordinate.
Returned values: (1) 1-8 represents 1-8 mines;
(2) If 0 is returned, no mines are found;
(3) return * representing the time when the coordinate is mine;
**************************************** **************************************/
CharRound_num_mines (IntI,IntJ)
{
IntK= 0;//Record the number of surrounding mines
If(Map [I] [j]= *)
{
Return *;
}
Else
{
If(I= 0)//0th rows
{
If(J= 0)//0th rows and 0th Columns
{
If(Map [I] [j+1]= *) K++;
If(Map [I+1] [J]= *) K++;
If(Map [I+1] [J+1]= *) K++;
}
Else If(J=N-1)//Column n-1 of row 0th
{
If(Map [I+1] [J]= *) K