12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
#include <iostream> #include <string> using namespace std; int main() { const int total = 13; int n, mtotal; bool winner = false; mtotal = total; do { if (mtotal > 0) { cout << "There are " << mtotal << " sticks" << endl; cout << "Player 1, pick a number between 1 and 4" << endl; cin >> n; if (n >= 1 && n <= 4) { cout << "You have removed " << n << " stick(s)" << endl; mtotal -= n; } else { cout << " Invalid number" << endl; } if (mtotal < 1 ) { winner = true; cout << " Player 2 wins" << endl; } } if (mtotal > 0) { cout << "There are " << mtotal << " sticks" << endl; cout << "Player 2, pick a number between 1 and 4" << endl; cin >> n; if (n >= 1 && n <= 4) { cout << "You have removed " << n << " stick(s)" << endl; mtotal -= n; } else { cout << " Invalid number " << endl; } if (mtotal < 1 ) { winner = true; cout << " Player 1 wins" << endl; } } }while(!winner); system("pause"); }