| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 655 人关注过本帖
标题:[分享]观察微生物 哈哈菜鸟也行
只看楼主 加入收藏
smsand
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-11-10
收藏
 问题点数:0 回复次数:0 
[分享]观察微生物 哈哈菜鸟也行

//进化论。。。。。。哈哈哈哈
#include<iostream>
using namespace std;

void life_circle(int [][20],int [][20]);


void life_info(int a[][20],int x,int y)
{

a[x][y]=1;
}

int main()
{
int a[20][20],b[20][20];
int i,j,x,y,count,times;
while(1)
{
for(i=0;i<21;i++)
{
for(j=0;j<21;j++)
{
a[i][j]=0;
b[i][j]=0;
}
}
cout<<"How many seeds do you want to give birth to?"<<endl;
cin>>count;
for(i=0;i<count;i++)
{
cout<<"The information of the seeds please"<<endl;
cin>>x>>y;
life_info(a,x,y);
}
cout<<"How many steps to go ahead?"<<endl;
cin>>times;
for(i=0;i<times;i++)
life_circle(a,b);
}
system("pause");

return 0;
}

void life_circle(int a[][20],int b[][20])
{
int i,j;

for(i=1;i<20;i++)
{for(j=1;j<20;j++)
{
b[i][j]=a[i-1][j-1]+a[i-1][j]+a[i-1][j+1]+a[i][j-1]+a[i][j+1]+a[i+1][j-1]+a[i+1][j]+a[i+1][j+1];
}

}
for(i=1;i<20;i++)
{
for(j=1;j<20;j++)
{
if(b[i][j]==3)
a[i][j]=1;
else
if(b[i][j]>3||b[i][j]<2)
a[i][j]=0;
else
;


if(a[i][j]==1)
cout<<"*";
else
cout<<" ";

}
cout<<endl;
}
cout<<endl;
cout<<endl;
cout<<endl;
}

观察微生物的变化 过多过少的邻居都会使微生物死亡

搜索更多相关主题的帖子: 分享 观察 微生物 
2006-12-06 13:58
快速回复:[分享]观察微生物 哈哈菜鸟也行
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014910 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved