lifemain.cpp

来自「这是本人精心搜集的关于常用图论算法的一套源码」· C++ 代码 · 共 36 行

CPP
36
字号
#include "iostream.h"
#include "utility.h"
#include "life.h"
void main( ) // Program to play Conway's game of Life.
/* Pre: The user supplies an initial configuration of living cells.
   Post: The program prints a sequence of pictures showing the changes in the conguration
         of living cells according to the rules for the game of Life.
   Uses: The classLife and its methodsinitialize(),print(),and update().
         The functions instructions(), user_says_yes(). */
{ void instructions( );   Life configuration;

  instructions( );
  configuration.initialize( );
  configuration.print( );
  cout << "Continue viewing new generations?\n ";
  while (user_says_yes( )) 
    {  configuration.update( );
       configuration.print( );
       cout << "Continue viewing new generations?\n";
    }
}
void instructions( )
/* Pre: None.
   Post: Instructions for using theLife program have been printed. */
{
  cout<<"Welcome to Conway's game of Life.\n";
  cout<<"This game uses a grid of size ";
  cout<<maxrow<<" by "<<maxcol<<" in which each\n";
  cout << "cell can either be occupied by an organism or not." << endl;
  cout << "The occupied cells change from generation to generation\n";
  cout << "according to how many neighboring cells are alive.\n";
}



⌨️ 快捷键说明

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