char PickRandomOption (void);
{
char option;
srand ( time_t (NULL) );
int value = rand()%3;
switch (value) // It occurs here at line (10)
//error C2447: '{' : missing function header
//(old-style formal list?)
{
case 0: option='s'; break;
case 1: option='x'; break;
case 2: option='p'; break;
}
return option;
}
int WhoWins (char a, char b)
{
switch (a)
{
case 's':
if (b=='x') return 1;
else if (b=='p') return 2;
else return 0;
case 'x':
if (b=='p') return 1;
else if (b=='s') return 2;
else return 0;
case 'p':
if (b=='s') return 1;
else if (b=='x') return 2;
else return 0;
default:
return -1;
}
}
int main ()
{
char you, me;
int mypoints=0;
int yourpoints=0;
int winner;
do {
cout << "\nEnter s, x or p ";
cout << "(s=stone, x=scissors, p=paper): ";
cin >> you;
me = PickRandomOption();
cout << "I say: " << me << "\n";
winner = WhoWins (you,me);
if (winner==0) cout << "Tied\n";
else if (winner==1) { cout << "You win\n"; yourpoints++; }
else if (winner==2) { cout << "I win\n"; mypoints++; }
else cout << "Sorry. You entered an Invalid option\n";