Your program should read in the values of N and M, and then the initial state of an N by M game of life. It should then loop through generations, printing out the state of the game and the number of live organisms after each generation, then pausing for the user to press return (so the generations don't go flying by so fast you can't see them!). Here is a sample output for a 10 by 20 game with a simple initial state:
Initial state: .................... .................... .................... .................... ....OOOOOOOOO....... .................... .................... .................... .................... .................... Generation 1, 21 alive .................... .................... .................... .....OOOOOOO........ .....OOOOOOO........ .....OOOOOOO........ .................... .................... .................... .................... press return: Generation 2, 16 alive .................... .................... ......OOOOO......... .....O.....O........ ....O.......O....... .....O.....O........ ......OOOOO......... .................... .................... .................... press return: Generation 3, 34 alive .................... .......OOO.......... ......OOOOO......... .....OOOOOOO........ ....OO.....OO....... .....OOOOOOO........ ......OOOOO......... .......OOO.......... .................... .................... press return: Generation 4, 16 alive ........O........... ......O...O......... .....O.....O........ ....O.......O....... ....O.......O....... ....O.......O....... .....O.....O........ ......O...O......... ........O........... .................... press return:and so forth.
Hint: Represent the cells as a charMatrix, with 'O' representing an organism and '.' representing an empty cell. This is easy to input and print. When it comes time to count neighbors, create an intMatrix whose elements are 1 in cells that are occupied, and 0 in cells that are empty. Use that to compute the number of neighbors for each cell, and then convert back to the charMatrix form for printing.
Hint: Edit an initial state using an editor with a fixed-width font, and then paste it into the console window every time you run your program. It's easier than re-typing the initial state every time.