// duyidu.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <time.h> using namespace std; int getDouzi(void) { int dz1,dz2; cout<<"按任意键开始roll点"; system("pause"); dz1 = 1+(rand()%6); dz2 = 1+(rand()%6); cout<<dz1<<"+"<<dz2<<"="<<dz1+dz2<<endl; return dz1+dz2; return 0; } enum States {Win=1,Lose,Contuine}; int _tmain(int argc, _TCHAR* argv[]) { int pNum,zNum; int ztime=1; //庄家丢骰子次数 States GameState; cout<<"丢先"<<endl; pNum = getDouzi(); switch(pNum) { case 7: case 11: GameState = Win; break; case 2: case 3: GameState = Lose; break; default: GameState = Contuine; break; } while (GameState==Contuine) { cout<<"庄家第"<<ztime<<"丢骰子"; zNum = getDouzi(); ztime ++; if(pNum==zNum) { GameState = Lose; } if (zNum==7) { GameState = Win; } else { GameState = Contuine; } } if(GameState==Win) { cout<<"你赢了"<<endl; } else { if(GameState==Lose) { cout<<"你输了"<<endl; } } system("pause"); return 0; } 我 7或者 11 直接赢 2或者3 直接输 如果其他的 庄家丢 庄家==我的 我输 庄家 7 我赢 否则 重新丢 知道分出胜负!!!!