64 730
Assignments Done
99,3%
Successfully Done
In September 2018

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
Expert's answer
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions