早教吧 育儿知识 作业答案 考试题库 百科 知识分享

关于C++的一个问题,懂英语的麻烦来帮下忙,很有趣的程序ThegameofLife,inventedbymathematicianJohnH.Conway,isintendedtomodellifeinasocietyoforganisms.Considerarectangulararrayofcells,eachofwhichmaycontainan

题目详情
关于C++ 的一个问题,懂英语的麻烦来帮下忙,很有趣的程序
The game of Life,invented by mathematician John H.Conway,is intended to model life in a
society of organisms.Consider a rectangular array of cells,each of which may contain an organism.
If the array is assumed to extend infinitely in both directions,each cell will have eight neighbors,the
eight cells surrounding it.Births and deaths occur according to the following rules:
a) An organism is born in an empty cell that has exactly three neighbors.
b) An organism will die from isolation if it has fewer than two neighbors.
c) An organism will die from overcrowding if it has more than three neighbors.
d) All other organisms survive to the next generation.
Write a program to play the game of Life and investigate the patterns produced by various initial
configurations.Some configurations die off rather quickly; others repeat a certain number of
generations; others change shape and size and may move across the array; and still others may
produce 'gliders' that detach themselves from the society and sail off into space.












▼优质解答
答案和解析
先定义一个3维的数组.为数组作初始化(各种不同初始状态下模型的运行情况),
a,用for循环判断,如果相邻的3个元素都为1就把这元素设为1更新数组,下面这情况是类式的,如果数组都为0那就说明灭绝了