The first issue, as already explained is the missing row variable.
However, the second is of a similar ilk, regarding the second part of the code...
Your second loop uses
i
from 0-49 and
j
from 0-1. You are only accessing
GridF
with
j + 1
. As a result
xGrid
and
yGrid
are always accessing the same index (1) - resulting in identical values.
As a "proof of concept", you should really have a single loop from 0-99 and access the array index using a single variable. If the code is a stripped down version of production code, then you must access the
GridF
array using a operation of both
i
and
j
.
I see a third problem in that your array has 100 values, but the loop for
i
only reaches 50.
A "proof of concept" solution would be the following:
for (int i = 1; i < 100; ++i)
{
xGrid = abs(GridF[i][0] - GridF[i - 1][0]);
xGrid *= xGrid;
cout << "xGrid=" << xGrid << endl;
yGrid = abs(GridF[i][1] - GridF[i - 1][1]);
yGrid *= yGrid;
cout << "yGrid=" << yGrid << endl;
result = sqrt(xGrid + yGrid);
cout << "Equation : " << result << endl;
}
Also note the obvious facts:
1) You will get 99 outputs, not 100,
2) There is no validation (if required for min-max values),
3) Consideration for the double-int casting.