早教吧作业答案频道 -->其他-->
关于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.
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那就说明灭绝了
a,用for循环判断,如果相邻的3个元素都为1就把这元素设为1更新数组,下面这情况是类式的,如果数组都为0那就说明灭绝了
看了 关于C++的一个问题,懂英语...的网友还看了以下:
如图是绿色植物叶肉细胞中光合作用与有氧呼吸过程其关系的图解,其中A-D表示相关过程,a-e表示有关 2020-05-14 …
根据图1-4给出的参数,指出该业务管理系统建设工程的关键路径,并计算出原来计划的总工期。 (2) D 2020-05-26 …
广义的生产关系包括( )A.直接生产过程中的关系 B.分配关系C.交换关系 D.消费关系 E.法律关 2020-06-05 …
一花样滑冰者,开始自传时,其动能为E0=1/2(J0)(ω0^2),然后她将手臂收回,转动惯量减少 2020-06-13 …
“光强”表示光的强弱程度的物理量(符号E),照射光越强,光强越大,单位为(cd).某实验中测得光敏 2020-06-14 …
如图为人体体液免疫的部分过程示意图,下列相关叙述正确的是()A.M细胞被同种抗原再次刺激时可增殖形 2020-07-15 …
某同学要测量一电压表的内阻,所备器材如下:A.待测电压表V(量程3V,内阻未知)B.定值电阻R0(内 2020-11-10 …
两只时间继电器和一只行程开关怎么控制电机来回,求电路图也就是说我需要开关开了电机运转一个来回碰到行程 2020-12-15 …
x+y+z=e^x有关梯度的计算设z=z(x,y)由方程x+y+z=e^x所确定,则在点(-1,0) 2020-12-19 …
甲图是与细胞生命历程有关的图解,乙图表示小鼠肌肉细胞的形成过程,请回答下列问题:(1)甲图A表示过程 2021-01-15 …