C++ Help trying to solve the puzzles on the spotify
<p>Hi I am trying to solve the puzzles on the spotify website - <a href="http://www.spotify.com/uk/jobs/tech/best-before/" rel="nofollow">http://www.spotify.com/uk/jobs/tech/best-before/</a></p>

<p>I'm writing it in C++ and im getting some very annoying results. I have an int called <code>pause</code> which is usless and does nothing, but when I delete it my program seems to return the wrong result.</p>

<pre><code>    #include &lt;iostream&gt; 
    #include &lt;string&gt;
    #include &lt;sstream&gt;

    using namespace std;
    int Year;
    int Month;
    int Day;

    int pause;  // &lt;--- My useless INT which when Deleted my code returns wrong output

    stringstream ss;
    string input;
    string in;
    bool loop=true;
    int date[3];
    bool DateFound=false;

            void Check_date();
            void Check_date()
        {

if(DateFound==false)
{
//Check if valid Year
if (date[1]&lt;2999 &amp;&amp; date[1]&gt;0 &amp;&amp; date[2]&gt;0 &amp;&amp; date[3]&gt;0) 
{   //check months &amp; days are valid
    if(date[2]==1 || date[2]==3 || date[2]==5 || date[2]==7 || date[2]==8 || date[2]==10 || date[2]==12){if(date[3]&lt;=31){DateFound=true;}}
    if(date[2]==4 || date[2]==6 || date[2]==9 || date[2]==11){if(date[3]&lt;=30){DateFound=true;}}
    //Check For Leap Year
    if (date[2]==2)
    {   if(date[3]&lt;28)DateFound=true;
        if(date[1]%4==0 &amp;&amp; date[3]&lt;=29)DateFound=true;
        if(date[1]%100==0 &amp;&amp; date[1]%400!=0 &amp;&amp; date[3]&gt;28)DateFound=false;
    }

if(DateFound==true){Year=date[1]; Month=date[2]; Day=date[3];}
}
}

      }

        void SwitchDate(){int temp; temp=date[2]; date[2]=date[3]; date[3]=temp; 

    Check_date();};
    void ShiftDate(int places)
    {   if(places==1)
        {
        int temp; temp=date[3]; date[3]=date[2]; date[2]=temp; temp=date[1]; date[1]=date[2]; date[2]=temp;  Check_date();
        }
        if(places==2)
        {
        int temp; temp=date[1]; date[1]=date[2]; date[2]=temp; temp=date[2]; date[2]=date[3]; date[3]=temp; Check_date();
    }
};

int main ()
{   

while(loop==true)
{
cin &gt;&gt; input;
for (int x=0, y=1; y&lt;4; y++, x++)
    {
        while (input[x] !='/' &amp;&amp; x !=input.length()) ss&lt;&lt;input[x++];
        ss&gt;&gt; date[y];
        ss.clear();
    }

//order small medium large

for (int x=3, temp; x!=0; x--)
{
    if (date[x] &lt; date[x-1]) 
        {   temp=date[x-1];
            date[x-1]=date[x];
            date[x]=temp;
        }
    if (x==1 &amp;&amp; (date[2] &gt; date[3] )) 
            {
                temp=date[3];
                date[3]=date[2];
                date[2]=temp;
            }

}

Check_date();//return true
SwitchDate();
ShiftDate(1);
SwitchDate();
ShiftDate(2);
SwitchDate();

//PRINT

cout &lt;&lt;Year; cout&lt;&lt; endl;
cout &lt;&lt;Month; cout&lt;&lt; endl;
cout &lt;&lt;Day; cout&lt;&lt; endl;

//          13/12/5

cout &lt;&lt;"Again? 'Y' or 'N' \n";
cin &gt;&gt;in;
if(in=="y" || in=="Y"){loop=true;}
if(in=="n" || in=="N"){loop=false;}
}

return 0;
}
</code></pre>
