I'm trying to take the difference of the two rows using the for loop. There are total four rows, so the result would be simply 3 numbers after subtraction and summations. But the loop provide additional results which are unreasonable!! Does anyone know why it happens?
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int v[4][3] = {
{1,2,3},
{3,4,5},
{6,7,8},
{9,10,11} };
cout << sizeof(v) << "\n";
float sq = 0;
for(int i = 0; i < 3; ++i){
for(int j = 0; j < 2; ++j){
sq += (v[i+1][j] - v[i][j]) + (v[i+1][j+1] - v[i][j+1]) + (v[i+1][j+2] - v[i][j+2]);
cout << "diff " << sq << endl;
}
}
cout << "final square of the numbers: " << sq << endl;
return 0;
}
``