早教吧作业答案频道 -->其他-->
关于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.CO(g)的燃烧热:△H=-283.0kJ/mol,则2CO2(g)=2C 2020-04-07 …
已知2H2(g)+O2(g)===2H2O(l)ΔH=-571.6kJ/mol,则关于方程式2H2 2020-04-07 …
已知2H2(g)+O2(g)═2H2O(l)△H=-571.6kJ/mol,则关于方程式2H2O( 2020-04-07 …
关于化学反应的△H的理解正确的是()A.△H>0的反应是吸热反应B.△H=ΣH(反应物)-ΣH(生 2020-04-11 …
关于化学反应的△H的理解正确的是()A、△H>0的反应是吸热反应B、△H=ΣH(反应物)-ΣH(生 2020-04-11 …
A市在B市的12km的位置,给B市发货的车以40km/时送货,以60km/时返回A市,往返1时10 2020-04-27 …
有机物A~H间存在如下的转化关系:已知:①F的结构中含有一个苯环,且仅含两个邻位的取代基;②H的结 2020-05-02 …
稀H2SO4为什么是非氧化性酸?一般情况下,S(+6)变成(+4)吗?我看的那些答案都说,主要体现 2020-05-14 …
点燃一支长20cm蜡烛,其燃烧时剩下的高度h(cm)与燃烧的时间t(h)的函数关系(1)这支蜡烛可 2020-05-16 …
蜡烛燃烧时,剩下的长度h(cm)是燃烧时间t(h)的一次函数,现测得蜡烛燃烧1h后,其长度为15c 2020-05-16 …