let's say we are taking row = 1 and col = 3 , then my loop terminates when it reaches value of j as 2 and with error segmentation fault...
std::cin >> row >> col;
std::vector<std::vector<int> > arr;
for ( int i = 0; i < row; i++ ) // first loop
{
std::vector<int> temp (col, 0);
arr . push_back (temp);
}
for ( int i = 0; i < arr . size (); i++ ) //second loop
{
for ( int j = 0; j < arr[ i ] . size (); j++ )
{
std::cin >> arr[ i ][ j ];
}
}
Aucun commentaire:
Enregistrer un commentaire