How to fill a two-dimensional vector of size n in n +1 with two for?
my code:
vector<vector<int> >v(n,vector<int>(n+1));
for(unsigned int i=0 ; i<n+1 ; i++){
for(unsigned int j=0 ; j<n ; j++){
cin>>v[i][j];
}
}
but it has segmantation fault error!!!!
tnx for helping
1
Expert's answer
2012-10-19T11:47:50-0400
Here is corrected code
int v[n+1][n]; for(unsigned int i=0 ; i<n+1 ; i++){ & for(unsigned int j=0 ; j<n ; j++){ & cin>>v[i][j]; & } }
Comments
Leave a comment