2 Player Nim (HELP!)

I need help with this. I'm not sure how to declare a winner, it won't show up. Please check and see what I did wrong. Thank you all so much in advanced

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
#include <iostream>
#include <string>
using namespace std;

int main()
{
	const int Sticks = 23;
	int Num, Total;
	string Player;
	string PlayerTwo;
	bool winner = false;
	
	Total = Sticks;

	cout << "Enter the starting player's name (no space)-->";
	cin >> Player;
	cout << "Enter the starting player's name (no space)-->";
	cin >> PlayerTwo;

	cout << "\n";
	

	while (!winner)
	{
 if (Total >= 0)
 cout << "There are " << Total << " matches" << endl;
 cout << "Player " << Player << " please enter the number of matches to remove--> " << endl;
 cin >> Num;

 if (Num > 0 && Num < 4)
 {
	
	 Total -= Num;
 }
 else {
	 cout << "Invalid Number" << endl;

	 if (Total == 0)
	 {
		 cout << "Game Over. Player " << Player << " is the winner!" << endl;
		 break;
	 }


 }

 if (Total >= 0)
	 cout << "There are " << Total << " matches" << endl;
	 cout << "Player " << PlayerTwo << " please enter the number of matches to remove--> " << endl;
	 cin >> Num;

 if (Num > 0 && Num < 4)
 {

	 Total -= Num;
 }
 else {
	 cout << "Invalid Number" << endl;
 }

 if (Total == 0)
 {
	 cout << "Game Over. Player " << PlayerTwo << " is the winner!" << endl;
	 break;
 }

	}

	

	

	cin.get(); cin.get(); //stytem("pause");
	return 0;

}
Topic archived. No new replies allowed.