Home > Back-end >  Use vector to realize two dimensional array interpolation problem, ask for advice
Use vector to realize two dimensional array interpolation problem, ask for advice

Time:09-25

Vector Arr.
Arr. Resize (dat_num + 1);//to a frame data reset container lines, equivalent to add a line;
Arr [dat_num]. Resize (12);//initialize a new line of space
Vector a;
for(int j=0; j<12. J++)
Amy polumbo ush_back (dbv1 [j]);//an array to be included in the container a
Arr. Insert (arr. The begin (), a. do v.begin (), a.e nd ());//insert a to the beginning of the arr???????
Dat_num + +;
Originally I want to use the vector to realize a number of two-dimensional arrays, each invocation is to increase the two-dimensional array arr a line, and then put the dbv1 this one-dimensional array into the arr [0] [I] the first line of the original data in turn up, why I use the arr. Insert (arr. The begin (), a. do v.begin (), a.e nd ()); T insert data, using arr. Push_back (a) is inserted into the last column also not line? Pray god give directions? Draw back when I used arr [I] when [j] we found all is 0.

CodePudding user response:

Arr. Insert (arr. The begin (), a);

CodePudding user response:

 
Arr. Insert (arr. The begin (), a);

Use the insert and the push_back are increased a row
Using the resize is pre-allocated good size, so you need to arr way [I] [j] such assignment
I hope it can help you

CodePudding user response:

refer to the second floor scribbler response:
 
Arr. Insert (arr. The begin (), a);

Use the insert and the push_back are increased a row
Using the resize is pre-allocated good size, so you need to arr way [I] [j] such assignment
I hope it can help you

Problem do as you say, arr [I] [j] can assignment, that I now how to modify to achieve insert? I mainly want to let the new one dimensional array inserts in the first row, two-dimensional array of pure with array up too much trouble every time,

Arr. Resize (dat_num + 1);//to a frame data reset container lines, equivalent to add a line;
Arr [dat_num]. Resize (12);//initialize a new line of space
This is not good size distribution? Every call a function dat_num + + equivalent to allocate a line to the ah, why the insert insert a line not line? Ask for advice

CodePudding user response:

refer to the second floor scribbler response:
 
Arr. Insert (arr. The begin (), a);

Use the insert and the push_back are increased a row
Using the resize is pre-allocated good size, so you need to arr way [I] [j] such assignment
I hope it can help you

Array2D. Resize (num, vector (12));
For (int t=0; T<12. T++)
{
VBV. Push_back (bv1 [t]);
}
Array2D. Push_back (VBV);

And what is the difference between the following?
Array2D. Resize (num, vector (12));
For (int t=0; T<12. T++)
{
[t]=bv1 array2D [I] [t];//calculation should be on the drawing program inside the
}
This can be really, I want to use array2D push_back (VBV), how should change?

CodePudding user response:

The resize equivalent to redistribute the array size,
Push_back and insert are dynamically add a row,

If every time you want to insert to the first row, directly
Arr. Insert (arr. The begin (), a); OK, no need to resize
  • Related