C++ Toothpicks program
<p>My program is made to play a game of toothpicks, I've been stuck on it for awhile. The goal is to get the computer to pull toothpicks out of a stack of 23 and the human would also do the same. So far, my logic isn't working it seems. The player is able to pull out an amount of toothpicks and it's being taken out of the total, but when the computer takes out toothpicks it only takes one toothpick. I made the program say how many are left and how many the computer takes out. It seems that since the computer always takes out one toothpick, there is always one toothpick remaining in the stack, which is obviously not mathematically correct. </p>

<pre><code>#include &lt;iostream&gt;
#include &lt;conio.h&gt;
#include &lt;cmath&gt;

using namespace std;

int main()
{

int toothpicks = 23, human, comp;


cout&lt;&lt;"TOOTHPICKS!!!!!" &lt;&lt;endl;

while (toothpicks &gt;0)
{
    cout&lt;&lt;"Human, take your toothpick(s)! But only between 1 and 3 toothpick(s), Thanks! ";
    cin&gt;&gt;human;

    toothpicks = toothpicks - human;
    cout&lt;&lt;toothpicks &lt;&lt;" toothpick(s) remaining" &lt;&lt;endl;

    if (toothpicks = 0)
    {
        cout&lt;&lt;"Human! You have prevailed!"&lt;&lt;endl;
        break;
    }

    if (toothpicks &gt;4)
    {
        comp = 4 - human;   
        cout&lt;&lt;"The computer took " &lt;&lt;comp &lt;&lt;" toothpick(s)" &lt;&lt;endl;
    }
    else if (toothpicks = 2)
    {
        comp = 1;
        cout&lt;&lt;"The computer took " &lt;&lt;comp &lt;&lt;" toothpick(s)" &lt;&lt;endl;
    }
    else if (toothpicks = 3)
    {
        comp = 2;
        cout&lt;&lt;"The computer took " &lt;&lt;comp &lt;&lt;" toothpick(s)" &lt;&lt;endl;
    }
    else if (toothpicks = 4)
    {
        comp = 3;
        cout&lt;&lt;"The computer took " &lt;&lt;comp &lt;&lt;" toothpick(s)" &lt;&lt;endl;
    }
    else if (toothpicks = 1)
    {
        comp = 1;
        cout&lt;&lt;"The computer took " &lt;&lt;comp &lt;&lt;" toothpick(s)" &lt;&lt;endl;
    }

    toothpicks = toothpicks - comp;
    cout&lt;&lt;toothpicks &lt;&lt;" toothpick(s) remaining";

    if (toothpicks = 0)
    {
        cout&lt;&lt;"The computer has prevailed!"&lt;&lt;endl;
        break;
    }

}

_getche();
return 0;
</code></pre>
