Here is my code:
vector<vector<int>> tranches_max(vector<vector<int>> x)
{
vector<vector<int>> y;
y[0].swap(x[0]);
return y;
}
int main() {
vector<vector<int>> x=
{
{2, 1, 0, 2},
{0, 1, 0, 3},
{1, 3, 0, 0},
{0, 2, 2, 0},
};
for (vector< vector<int> >::size_type u = 0; u < x.size(); u++)
{ for (vector<int>::size_type v = 0; v < x[u].size(); v++)
{ cout << x[u][v] << " ";
}
cout <<endl;
}
vector<vector<int>> y= tranches_max(x);
for (vector< vector<int> >::size_type u = 0; u < y.size(); u++)
{ for (vector<int>::size_type v = 0; v < y[u].size(); v++)
{ cout << y[u][v] << " ";
}
cout <<endl;
}
return 0;
}
My code does not generate an error, but it crashes .. I think the copy is the problem .. Do you have any idea?
Thank you.