濮院物流公司:数据结构课程设计 Game of life

来源:百度文库 编辑:高考问答 时间:2024/04/29 20:27:55
1.The neighbours of a given cell are the 8 cells that touch it vertically, horizontally, or diagonally
2.If a cell is alive but either has no neighbours cells alive or only one alive, then in the next generation the cell dies of loneliness.
3.If a cell is alive and has four or more neighbours cells also alive, then in the next generation the cell dies of overcrowding.
4.A living cell with either 2 or 3 neighbours remains alive in the next generation.
5.If a cell is dead, then in the next generation it will become alive if it has exactly 3 neighbours cells, no more or fewer, that are already alive. All other dead cell remain dead in the next generation.

class for the Game of Life

Class Life {
public:
void initialize();
void generation();
private:
int map[maxrow][maxcol];
int neighbour_count(int row, int col);
}

Entry of the program

void main()
{
Life e;
e.initialize();
while ( keep_going() )
e.generation();
e.draw();
}
}

上面给出的是题目的解释,class和main函数,怎么编这个程序