GameofLife - #include <iostream.h> #include...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream.h> #include <conio.h> #include <fstream.h> #include <windows.h> #include <cstring.h> /************************************************** Name: Hung Truong Program: Game of Life Instructor: Mr. Barkeshli Purpose: Input: Output: **************************************************/ const int TOPX=5;const int Y_SIZE=40; const int X_SIZE=70; const int TOPY=5;const char char_Alive='x';const char char_Dead='.'; void Init(int array[][Y_SIZE+2]); // To initiate an array to be all '0' void ShowWorld(int array[][Y_SIZE+2]); // Show the array to the screen void PutCell(int i, int j, bool Alive); //Use to mark the position the alive or dead void Step(int array[][Y_SIZE+2]); // Function of step- for one generation of cell lives int Neighbor(int array[][Y_SIZE+2],int x, int y); // Return the numbers of alive cell among point (x,y) void WriteIn(ofstream &fout,int array[][Y_SIZE+2]); // Use to write the data of array into a file void Play(int array[][Y_SIZE+2]); // Play function- nonstop generation of cell lives void ReadIn(ifstream &fin, int array[][Y_SIZE+2]); // Use to read the data into the array from a file int Random(int lo, int hi); // Random a number from integer lo to hi bool t=true; bool circular=true; char c; main() { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(3); ifstream fin; ofstream fout; while (t==true)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/20/2011 for the course CS 2 taught by Professor Barkeshli during the Spring '11 term at Pasadena City College.

Page1 / 6

GameofLife - #include &lt;iostream.h&gt; #include...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online