In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge of this article "how to roll a double dice game based on C++", so the editor summarizes the following, with detailed contents and clear steps, which can be used for reference. I hope you can get something after reading this article. Let's take a look at this "how to achieve double dice games based on C++" article.
Among the most popular gaming games is a dice game called "double Dice" (craps), which is very popular in places of entertainment and streets around the world. The rules of the game are simple:
The player rolls two dice. Each dice has six sides, containing 1, 2, 3, 4, 5 and 6 points respectively. After rolling the dice, calculate the sum of the points of the two upward faces.
1. If the total number of points thrown for the first time is 7 or 11, then the player wins
2. If the first throw points are only related to event 2, 3 or 12 (called "craps"), then the player loses (that is, the dealer wins)
3. If the number of points thrown for the first time is only 4, 5, 6, 7, 8, 9 or 10, then this sum becomes the player's "target point". To win, the player must roll the dice continuously until the points are the same as the target points, that is, "get the points". But before you get a point, if you throw 7, you will lose.
# include # include # include using namespace std; unsigned int rollDice (); int main () {enum Status {CONTINUE, WON, LOST}; / / this is to customize a variable type, which is similar to int,double, that is, to put it bluntly, it is to set an enumerated class variable class / / and the keyword of this class is Status. Variables defined by this type can only take several values in the enumeration, and these values correspond to numbers. Srand (static_cast (time (0)); unsigned int myPoint = 0; Status gameStatus = CONTINUE; unsigned int sumOfDice = rollDice (); switch (sumOfDice) {case 7: case 11: gameStatus = WON; break; case 2: case 3: case 12: gameStatus = LOST; break Default: gameStatus = CONTINUE; myPoint = sumOfDice; cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.