CS 1355
Introduction to Programming in C
Monday 2006.10.16 (Week 6)
Lecture notes (at http://r638-2.cs.nthu.edu.tw/C/notes/11.txt)
Chapter 5 continued (pp.161-169)
- Book example: Game of Chance
- Enumerated data type
- Storage Classes (auto, register, extern, static)
- Scoping rules
Rule: Game of Chance
- roll two dice (each is 1, 2, 3, 4, 5, 6)
- on first throw:
if sum is 7 or 11 => player wins
if sum is 2, 3, 12 => player loses
if sum is 4,5,6,8,9,10 => sum becomes point, throw again.
- on subsequent throw:
if sum is 7 => player loses
if sum is point => player wins
all other sum => throw again.
How to solve this problem?
1. concept of "state" or "status" (