⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 风格经典!!!! 小游戏 新手上路。
💻 CPP
字号:
/*Simulation of Conway's game of life on a bounded grid
  Pre: The user must supply an initial configuration of living cells.
  Post: The programme prints a sequence of maps showing the changes in the configuration ofliving
         cells according to the rules for the game of life.
  uses:function Initialize,Writemap,NeighborCount,and UserSaysYes                    */


#include "common.h"    /*common.h include filesand definitions*/
#include "life.h"      /*life's defines,typedefs,and prototypes*/
#include "functions.h" /*functions.h include functions will be used*/
      
void main(void)
{
	int row,col;
	Grid map;             /*current generation*/
	Grid newmap;          /*next generation*/
	Initialize(map);
	Writemap(map);
	printf("This is the initial configuration you have chosen.\n"
		   "press <Enter>to continue.\n");
	while(getchar()!='\n')
		;
	do{
		for(row=1;row<=MAXROW;row++)
			for(col=1;col<=MAXCOL;col++)
				switch(NeighborCount(map,row,col))
			{
				case 0:
				case 1:     newmap[row][col]=DEAD;break;
				case 2:		newmap[row][col]=newmap[row][col];break;
				case 3:		newmap[row][col]=ALIVE;break;
				case 4:
				case 5:
				case 6:
				case 7:
				case 8:		newmap[row][col]=DEAD;break;
			}
			Copymap(map,newmap);
			Writemap(map);
			printf("Do you wish to continue viewing the new denerations");
	}while(UserSaysYes());
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -