Answer to Question #16718 in C++ for sahar

Question #16718
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];
& }
}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS