📄 craps.cpp
字号:
#include <iostream>using namespace std;#include "dice.h"// simulate one games of craps (rules from W. Weaver, Lady Luck, 1982// Doubleday Press --- as given in Charles Whitney, Random Process in// Physical Systems, 1990, Wiley Interscience)//// written 5/17/94, modified 6/21/95, modified 4/19/99// prototypesint RollTwo();int main(){ int sum; int point = RollTwo(); // initial point switch (point) { case 7: case 11: cout << "natural winner!!" << endl; break; case 2: case 3: case 12: cout << "craps!! a loser" << endl; break; default: while (true) { sum = RollTwo(); if (sum == point) { cout << "got your point! a winner" << endl; break; } if (sum == 7) { cout << "loser, lost going for " << point << endl; break; } } } return 0;}int RollTwo()//postcondition: returns sum of rolling two dice// prints values rolled { Dice d(6); int first = d.Roll(); int second = d.Roll(); cout << "rolling ... " << first << " " << second << endl; return first + second;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -