Game of life load and save
code/4_io/exercises/gol_with_io.cpp here you will find the game of life with load and save stub code. OR use your own game of life from yesterday.
Build the program. You'll see it asks for an input file. If you type
rand it will just generate a random pattern and run for
MAX_TICS iteration and then exit.
You should do the following:
- Add save functionality by following the instructions in the
- Once you have it working, set the
MAX_TICS(near the top of the file) to something lower and run the program. After
MAX_TICSit will save the file. Open it in an editor and see if the world is there.
- Now complete the
loadWorldfunction by following the instructions.
- Run the program and try inputting one of your saved worlds to see if it worked.
Now go to this website:
and find some good patterns. Code them into your world by hand in a text editor and load them. See if they work as they should. Gosper glider gun is especially nice to try.
Numerical analysis from file
code/4_io/exercises/heathrow.dat. Here you will find meteorological data measurements at Heathrow since 1984. There are seven columns that mean the following:
Month number (integer)
Air frost (integer)
Sun hours (float)
Missing data is represented by the string "---".
Write a program that reads in all the data and find:
- The overall min and max temperatures (look up std::min/max) and the midpoint between these two.
- The frostiest December.
- The rainiest month of the year on average.
You should get the following answers:
Temperatures - min = -4.6, max = 28.2, mean = 11.8
Frostiest December = 12 / 1962, air frost = 22
Raniest month = October