Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Need Help. The Game of Life program for C++

I need help on how to build the code for the game of life using two dimensional arrays. Im supposed to ask the user to enter the number of rows and columns of each live cell. Dont know where to go from there.
I would appreciate any help.

Heres what I got:

#include
#include
#include
using namespace std;

void main (void)
{


cout<<"The Game of Life."<<endl<<endl;

cout<<"Do you want to define a new board?(y/n)"<<endl;
cin>>New;
if(New == 'y')
cout<<"What is the size that you want the board to be?"<<endl;
cin>> size;

cout<<"Choose from the following options.."<<endl<<endl;
cout<<"(1) Enter the information from the keyboard."<<endl<<endl;
cout<<"(2) Read the information from the data file."<<endl<<endl;
cout<<"(3) Load a predefined board."<<endl<<endl;
cin>>options;
if(options == 1)
cout<<"Enter the number of rows (from 5 to 20)"<<endl;
cin>>rows;

cout<<"Enter the number of columns (from 5 to 40)"<<endl;
cin>>columns;




cout<<"Enter the row and column of each live cell."<<endl<<endl;

do
{

cout<<"Enter the row for a live cell."<<emdl;
cin>>liveRow;

cout<<"Enter the column"<<endl;
cin>>liveCol;

cout<<"Do you want to enter another one?(y/n)"<<endl;
cin>>another;
}
while(another == 'y');

Comments

  • bilderbikkelbilderbikkel Member Posts: 754
    : I need help on how to build the code for the game of life using two
    : dimensional arrays. Im supposed to ask the user to enter the number
    : of rows and columns of each live cell. Dont know where to go from
    : there.
    : I would appreciate any help.
    :

    1) Create a 2D std::vector (that is, a 'std::vector >' ) of correct size
    2) Initialize it
    3) Show it on screen
    4) Create the next 2D std::vector from the old
    5) Overwrite the old 2D std::vector by the old
    6) Go to step 3

    Good luck, Bilderbikkel
    bilderbikkel
Sign In or Register to comment.