I'm having some trouble with outputting data from the vectors I have created.
Here is the code:
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main() {
vector<double> XY;
vector<vector<double>> Cords;
for (double i = 0; i < 10; i++)
{
cout << i << "\n";
for (double j = 0; j < 1; j++)
{
double X = i;
double Y = i + 1;
XY.push_back(X);
XY.push_back(Y);
Cords.push_back(XY);
}
cout << "[" << Cords[i][0] << "," << Cords[i][1] << "]" << "\n";
}
}
the output I receive is:
0
[0,1]
1
[0,1]
2
[0,1]
3
[0,1]
4
[0,1]
5
[0,1]
6
[0,1]
7
[0,1]
8
[0,1]
9
[0,1]
The code is supposed to output the newest set of coordinates on every iteration of the main loop but it keeps outputting the first set [0,1] instead of the desired [0,1] [1,2] [2,3] etc...