Доброго времени суток уважаемые форумчане.
У меня проблема. Как можно удалить строку из вектора вложенного?
| Код | using namespace std; typedef vector<vector<int>> MySuperVectorParent; typedef vector<int> MySuperVectorChild; const int ARRAY_SIZE = 10;
void ShowToSuperVector(MySuperVectorParent &theVector); //void DeleteRowFromMatrix(MySuperVectorParent &theVector); void main() { MySuperVectorParent theVector(ARRAY_SIZE,MySuperVectorChild(ARRAY_SIZE)); for(int i=0;i<ARRAY_SIZE;i++) { for(int j=0;j<ARRAY_SIZE;j++) { theVector[i][j] = rand(); } } cout<<"Row to delete: \n"; int row_to_delete=0; cin>>row_to_delete; theVector[row_to_delete].erase(std::remove(theVector[row_to_delete].begin(),theVector[row_to_delete].end(),0)); //theVector.erase(theVector.begin()+1,theVector.begin()+1); ShowToSuperVector(theVector); }
void ShowToSuperVector(MySuperVectorParent &theVector) { if(theVector.empty()) { cout<<"Matrix is empty.\n"; return; } for(int i=0;i<theVector.size();i++) { cout<<"col "<<i<<" "; } cout<<"\n\n\n"; for(int i=0;i<theVector.size();i++) { for(int j=0;j<theVector.size();j++) { cout<<theVector[i][j]<<" "; if(theVector[i][j]<40000 && theVector[i][j]<1000) cout<<" "; } cout<<"\n"; } }
|
Заранее благодарен.
|