// Snail Race
#include <iostream>
#include <ctime>
int race (int, int);
void race ();
int menu ();
int bet (int);
void init ();
int money = 200;
int main ()
{
using std::cout;
init ();
int act;
cout<< "W e l c o m e\n";
while (act == menu ())
{
switch (act)
{
case 1:
case 2:
case 3:
::money += race (bet (act), act);
break;
case 4:
race ();
break;
}
}
return 0;
}
int menu ()
{
using std::cout;
using std::cin;
int act;
cout<< "Hand " << money << "gold\n";
do
{
cout<< "The Race\n""1) Bet on Ⅰ\n""2) Bet on Ⅱ\n""3) Bet on Ⅲ\n""4) Spectate\n""0) Depart\n""\n[Enter]: ";
cin>> act;
} while ( act < 0 || act > 4);
return act;
}
int bet (int act)
{
using std::cout;
using std::cin;
int bet;
cout<< "Snail " << act << " it is\n"
<< "Now, what is your bet?\n[Enter]: ";
cin>> bet;
return bet;
}
void race()
{
race (0,0);
}
int race (int money, int act)
{
using std::cout;
using std::rand;
int outcome = rand () % 3 + 1;
cout<< "-Klutch-\nThey're full of energy, today!\n\n"
<< outcome << " is our winner of today!\n";
if (outcome == act)
{
cout<< "Here is your profit\n";
return 2 * money;
}
else
{
cout<< "Oh..";
return -1 * money;
}
init ();
{
using std::srand;
using std::time;
srand (unsignedint(time(0))); //unsigned不要on srand
}