Trying to isolate certain array items and evaluate them for equality
<p>I've got an fstream input file that has [N] lines or items. I've written code to decide which items are triangles and which are rectangles and which are circles. I've got to isolate just the triangle items and then compare them to see if they are equal to +/- 0.1 the area of all the other triangle items. Then I have to cout the equal pairs of items as uppercase char letters. </p>

<p>Here's my code so far but it's not working correctly. It's giving me the last item in the array plus one that doesn't exist. How do I fix this?</p>

<pre><code>// ........................................................
// 4. List any triangular blocks that are the same size.
// ........................................................

float TAE = 0.0;
float ItmM = 0.0;

for (int i=0; i&lt;M; i++)
{
  if (btype[i] == Triangles)
  {
    TA[i] = (0.5 * (D[i] * E[i]));

    TAE = TA[i+1];

    if ((TA[i] - 0.1) &lt;= TAE &lt;= (TA[i] + 0.1))
    {
      TAE = TA[i];
      ItmN = i;
      ItmM = i+1;
    }
  }
}
cout &lt;&lt; "4. Triangular blocks that are the same size = "
     &lt;&lt; (char)('A' + ItmN) &lt;&lt; "&amp;" &lt;&lt; (char)('A' + ItmM)
     &lt;&lt; endl;
</code></pre>
