title: C++ Small Straight (like yahtzee or poker). 5 Dice roll (1234)/(2345)/(3456)
body: <p>Im a beginner with C++ and this is for homework but Im stuck. I have one remaining problem and then im finished. 
  I can'T think of an algorithm that will tell if the user entered a small straight (1234) or (2345) or (3456). 
  I know how to do it using a loop but is it possible to not use a loop? When this was assigned, we did not learned about loops yet. I think we are only suppose to use if statements. 
  I started coding for it (I wrote what the dice can be, but cant figure out how to let only 4 dice go straight without an array and loop). Im stuck! Please help!
  Can you also check at my code and see if there is anything wrong so far.</p>
  
  <p>Assigned Problem:</p>
  
  <p>Playing poker with dice. (Kinda like Yahtzee)</p>
  
  <p>•   Have the user enter 5 dice rolls (1-6) in any order.  Have the user type in 5 numbers.  If any are outside of the 1 to 6 inclusive range, just end the program.</p>
  
  <p>•   Count and print the number of ones entered.</p>
  
  <p>•   Count and print the number of twos entered.</p>
  
  <p>•   Count and print the number of threes entered.</p>
  
  <p>•   Count and print the number of fours entered.</p>
  
  <p>•   Count and print the number of fives entered.</p>
  
  <p>•   Count and print the number of sixes entered.</p>
  
  <p>•   Tell if there are three or more dice the same.</p>
  
  <p>•   Tell if there are four or more dice the same.</p>
  
  <p>•   Tell if there are five dice the same.</p>
  
  <p>•   Tell if there is a full house, 3 the same and 2 the same.</p>
  
  <p>•   Tell if there is a long straight ... 1 2 3 4 5 or 2 3 4 5 6</p>
  
  <p><strong>• Tell if there is a small straight  (1 2 3 4) or (2 3 4 5) or (3 4 5 6)</strong></p>
  
  <p>My Code:</p>
  
  <pre><code>int main(int argc, char** argv)
  {
  //
  int Roll1, Roll2, Roll3, Roll4, Roll5;
  int numberOf1s = 0, numberOf2s = 0, numberOf3s = 0, numberOf4s = 0, numberOf5s = 0, numberOf6s = 0;
  bool TwoOfaKind = false;
  bool ThreeOfaKind = false;
  cout &lt;&lt; "Roll 5 dice. Enter them below." &lt;&lt; endl;
  cout &lt;&lt; "Roll 1: ";
  cin &gt;&gt; Roll1;
  cout &lt;&lt; "Roll 2: ";
  cin &gt;&gt; Roll2;
  cout &lt;&lt; "Roll 3: ";
  cin &gt;&gt; Roll3;
  cout &lt;&lt; "Roll 4: ";
  cin &gt;&gt; Roll4;
  cout &lt;&lt; "Roll 5: ";
  cin &gt;&gt; Roll5;
  
  if (Roll1 &gt; 6 || Roll1 &lt; 1 || Roll2 &gt; 6 || Roll2 &lt; 1 || Roll3 &gt; 6 || Roll3 &lt; 1 || Roll4 &gt; 6 || Roll4 &lt; 1 || Roll5 &gt; 6 || Roll5 &lt; 1 )
  {
     exit(1);
  }
  
  if (Roll1 == 1)
  {
      numberOf1s += 1;
  }
  if (Roll2 == 1)
  {
      numberOf1s += 1;
  }
  if (Roll3 == 1)
  {
      numberOf1s += 1;
  }
  if (Roll4 == 1)
  {
      numberOf1s += 1;
  }
  if (Roll5 == 1)
  {
      numberOf1s += 1;
  }
  cout &lt;&lt; "There are " &lt;&lt; numberOf1s &lt;&lt; " ones." &lt;&lt; endl;
  
  if (Roll1 == 2)
  {
      numberOf2s += 1;
  }
  if (Roll2 == 2)
  {
      numberOf2s += 1;
  }
  if (Roll3 == 2)
  {
      numberOf2s += 1;
  }
  if (Roll4 == 2)
  {
      numberOf2s += 1;
  }
  if (Roll5 == 2)
  {
      numberOf2s += 1;
  }
  cout &lt;&lt; "There are " &lt;&lt; numberOf2s &lt;&lt; " twos." &lt;&lt; endl;
  
  if (Roll1 == 3)
  {
      numberOf3s += 1;
  }
  if (Roll2 == 3)
  {
      numberOf3s += 1;
  }
  if (Roll3 == 3)
  {
      numberOf3s += 1;
  }
  if (Roll4 == 3)
  {
      numberOf3s += 1;
  }
  if (Roll5 == 3)
  {
      numberOf3s += 1;
  }
  cout &lt;&lt; "There are " &lt;&lt; numberOf3s &lt;&lt; " threes." &lt;&lt; endl;
  
  if (Roll1 == 4)
  {
      numberOf4s += 1;
  }
  if (Roll2 == 4)
  {
      numberOf4s += 1;
  }
  if (Roll3 == 4)
  {
      numberOf4s += 1;
  }
  if (Roll4 == 4)
  {
      numberOf4s += 1;
  }
  if (Roll5 == 4)
  {
      numberOf4s += 1;
  }
  cout &lt;&lt; "There are " &lt;&lt; numberOf4s &lt;&lt; " fours." &lt;&lt; endl;
  
  if (Roll1 == 5)
  {
      numberOf5s += 1;
  }
  if (Roll2 == 5)
  {
      numberOf5s += 1;
  }
  if (Roll3 == 5)
  {
      numberOf5s += 1;
  }
  if (Roll4 == 5)
  {
      numberOf5s += 1;
  }
  if (Roll5 == 5)
  {
      numberOf5s += 1;
  }
  cout &lt;&lt; "There are " &lt;&lt; numberOf5s &lt;&lt; " fives." &lt;&lt; endl;
  
  if (Roll1 == 6)
  {
      numberOf6s += 1;
  }
  if (Roll2 == 6)
  {
      numberOf6s += 1;
  }
  if (Roll3 == 6)
  {
      numberOf6s += 1;
  }
  if (Roll4 == 6)
  {
      numberOf6s += 1;
  }
  if (Roll5 == 6)
  {
      numberOf6s += 1;
  }
  cout &lt;&lt; "There are " &lt;&lt; numberOf6s &lt;&lt; " sixes." &lt;&lt; endl &lt;&lt; endl;
  if (numberOf1s == 2 || numberOf2s == 2 || numberOf3s == 2 || numberOf4s == 2 || numberOf5s == 2 || numberOf6s == 2)
  {
      TwoOfaKind = true;
  }
  if (numberOf1s == 3 || numberOf2s == 3 || numberOf3s == 3 || numberOf4s == 3 || numberOf5s == 3 || numberOf6s == 3)
  {
      cout &lt;&lt; "Yes three of a kind!" &lt;&lt; endl;
      ThreeOfaKind = true;
  }
  else
  {
      cout &lt;&lt; "No three of a kind" &lt;&lt; endl;
  }
  
  if (numberOf1s == 4 || numberOf2s == 4 || numberOf3s == 4 || numberOf4s == 4 || numberOf5s == 4 || numberOf6s == 4)
  {
      cout &lt;&lt; "Yes four of a kind!" &lt;&lt; endl;
  }
  else
  {
      cout &lt;&lt; "No four of a kind" &lt;&lt; endl;
  }
  
  if (numberOf1s == 5 || numberOf2s == 5 || numberOf3s == 5 || numberOf4s == 5 || numberOf5s == 5 || numberOf6s == 5)
  {
      cout &lt;&lt; "Yes five of a kind!" &lt;&lt; endl;
  }
  else
  {
      cout &lt;&lt; "No five of a kind" &lt;&lt; endl;
  }
  
  //
  if (TwoOfaKind == true &amp;&amp; ThreeOfaKind == true)
  {
       cout &lt;&lt; "Yes Full House!" &lt;&lt; endl;
  }
  else
  {
      cout &lt;&lt; "No Full House" &lt;&lt; endl;
  }
  
  //
  if (Roll1 == Roll2 &amp;&amp; Roll2 == Roll3 &amp;&amp; Roll3 == Roll4 &amp;&amp; Roll4 == Roll5)
  {
      cout &lt;&lt; "No Long Straight" &lt;&lt; endl;
  }
  else
  {
      if (((Roll1 &gt;= 1 &amp;&amp; Roll1 &lt; 6) &amp;&amp; (Roll2 &gt;= 1 &amp;&amp; Roll2 &lt; 6) &amp;&amp; (Roll3 &gt;= 1 &amp;&amp; Roll3 &lt; 6) &amp;&amp; (Roll4 &gt;= 1 &amp;&amp; Roll4 &lt; 6) &amp;&amp; (Roll5 &gt;= 1 &amp;&amp; Roll5 &lt; 6)) &amp;&amp; (Roll1 != Roll2 &amp;&amp; Roll2 != Roll3 &amp;&amp; Roll3 != Roll4 &amp;&amp; Roll4 != Roll5))
      {
          cout &lt;&lt; "Yes Long Straight!" &lt;&lt; endl;
      }
      else if (((Roll1 &gt; 1 &amp;&amp; Roll1 &lt;= 6) &amp;&amp; (Roll2 &gt; 1 &amp;&amp; Roll2 &lt;= 6) &amp;&amp; (Roll3 &gt; 1 &amp;&amp; Roll3 &lt;= 6) &amp;&amp; (Roll4 &gt; 1 &amp;&amp; Roll4 &lt;= 6) &amp;&amp; (Roll5 &gt; 1 &amp;&amp; Roll5 &lt;= 6)) &amp;&amp; (Roll1 != Roll2 &amp;&amp; Roll2 != Roll3 &amp;&amp; Roll3 != Roll4 &amp;&amp; Roll4 != Roll5))
      {
          cout &lt;&lt; "Yes Long Straight!" &lt;&lt; endl;
      }
      else
      {
          cout &lt;&lt; "No Long Straight" &lt;&lt; endl;
      }
  
  //***HELP ME HERE PLEASE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!***
  if (Roll1 == Roll2 &amp;&amp; Roll2 == Roll3 &amp;&amp; Roll3 == Roll4 &amp;&amp; Roll4 == Roll5)
  {
      cout &lt;&lt; "No Small Straight" &lt;&lt; endl;
  }
  else
  {
      if (((Roll1 &gt; 1 &amp;&amp; Roll1 &lt;= 4) &amp;&amp; (Roll2 &gt; 1 &amp;&amp; Roll2 &lt;= 4) &amp;&amp; (Roll3 &gt; 1 &amp;&amp; Roll3 &lt;= 4) &amp;&amp; (Roll4 &gt; 1 &amp;&amp; Roll4 &lt;= 4) &amp;&amp; (Roll5 &gt; 1 &amp;&amp; Roll5 &lt;= 4)) &amp;&amp; (Roll1 != Roll2 &amp;&amp; Roll2 != Roll3 &amp;&amp; Roll3 != Roll4 &amp;&amp; Roll4 != Roll5))
      {
          cout &lt;&lt; "Yes Small Straight!" &lt;&lt; endl;
      }
      else if (((Roll1 &gt; 1 &amp;&amp; Roll1 &lt;= 5) &amp;&amp; (Roll2 &gt; 1 &amp;&amp; Roll2 &lt;= 5) &amp;&amp; (Roll3 &gt; 1 &amp;&amp; Roll3 &lt;= 5) &amp;&amp; (Roll4 &gt; 1 &amp;&amp; Roll4 &lt;= 5) &amp;&amp; (Roll5 &gt; 1 &amp;&amp; Roll5 &lt;= 5)) &amp;&amp; (Roll1 != Roll2 &amp;&amp; Roll2 != Roll3 &amp;&amp; Roll3 != Roll4 &amp;&amp; Roll4 != Roll5))
      {
          cout &lt;&lt; "Yes Small Straight!" &lt;&lt; endl;
      }
      else if (((Roll1 &gt; 2 &amp;&amp; Roll1 &lt;= 6) &amp;&amp; (Roll2 &gt; 2 &amp;&amp; Roll2 &lt;= 6) &amp;&amp; (Roll3 &gt; 2 &amp;&amp; Roll3 &lt;= 6) &amp;&amp; (Roll4 &gt; 2 &amp;&amp; Roll4 &lt;= 6) &amp;&amp; (Roll5 &gt; 2 &amp;&amp; Roll5 &lt;= 6)) &amp;&amp; (Roll1 != Roll2 &amp;&amp; Roll2 != Roll3 &amp;&amp; Roll3 != Roll4 &amp;&amp; Roll4 != Roll5))
      {
          cout &lt;&lt; "Yes Small Straight!" &lt;&lt; endl;
      }
     else
     {
         cout &lt;&lt; "No Small Straight" &lt;&lt; endl;
     }
  }
  
  return 0;
  </code></pre>
  
  <p>}</p>