Mine game (pure C implementation) (1)

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.