C/C++ on Linux/Unix

Moderators: Lundin
Number of threads: 314
Number of posts: 633

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
i badly need ur help.. Posted by destian_kemuel on 19 Aug 2010 at 1:52 PM
Im trying to solve this problem..but dunno how..
im just a beginner using c++ as a language..
can anybody help me code this one??..pleaseeee..
pleaseee..any help is very much appreciated..
This is a one player game of a simplified version of the popular computer game
minesweeper. First, the user is asked if he or she wants to play on a 5x5 grid or 10x10
grid. You have two 2-dimensional arrays that contains information about your grid. An
entry in the array should either contain a 0 or 1. A 1 signifies that there is a bomb in
that location, and a 0 if none.
For example, given the array:
int bombList5by5[][]={{0, 0, 1, 0, 0},
{0, 0, 0, 0, 0},
{0, 1, 0, 0, 0},
{0, 0, 0, 1, 1},
{0, 1, 1, 0, 0}};
Given the bomb list, we have 6 bombs on our list. The bombs are located in (row,col)
cells, (0,2), (2,1), (3,3), (3,4), (4,1) and (4,2).
If the user chooses a cell that contains a bomb, the game ends and all the bombs are
displayed. If the user chooses a cell that does not contain a bomb, a number appears at
that location indicating the number of neighbors that contain bombs. The game should
end when all the cells that do not contain bombs have been marked (player wins) or
when the user steps on a bomb(player loses).
Here's a sample output of the game, given the bombList5by5.
Welcome to Minesweeper!
Choose size of grid (Press 1 for 5x5, Press 2 for 10x10): 1
[ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
Enter row and column of the cell you want to open[row col]: 1 1
[ ] [ ] [ ] [ ] [ ]
[ ] [2] [ ] [ ] [ ]
[ ] [ ] [] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
Enter row and column of the cell you want to open[row col]: 3 2
[ ] [ ] [ ] [ ] [ ]
[ ] [2 ] [ ] [] [ ]
[ ] [ ] [ ] [ ] [ ]
[ ] [ ] [4 ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
Enter row and column of the cell you want to open[row col]: 0 2
[] [ ] [ ] [ ] [ ]
[ ] [2] [ ] [] [ ]
[ ] [X ] [ ] [ ] [ ]
[ ] [ ] [4] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
Ooppps! You stepped on a bomb. Sorry, game over!
Report
Do not cross-post Posted by bilderbikkel on 21 Aug 2010 at 12:47 AM
Please, do not cross-post your questions.

Google is your friend.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.