[closed]

May 27, 2013 at 2:19pm
===
Thanks, guys
Last edited on May 27, 2013 at 2:44pm
May 27, 2013 at 2:25pm
What the problem here?

Easy to notice:
* You are missing void before init()
* Delete semicolon on line 99
* You forgot closing brace in race() function.

Your compiler should tell you all this.
May 27, 2013 at 2:41pm
lol I've just fixed on my own (I hate high school teachers.. 3;
May 27, 2013 at 2:42pm
they confuze us with unhelpful tricks that looks reasonable for their dramatic appearance hah
May 27, 2013 at 2:52pm
Putting original code back. Please, do not delete your question after you get an answer. It is considered rude.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// 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 (unsigned int(time(0))); //unsigned不要on srand
}
Topic archived. No new replies allowed.