outputting a row of a vector
this has been omitted. Does not follow rules.
c++ loops vector
add a comment |
this has been omitted. Does not follow rules.
c++ loops vector
In the comment below you stated that you want to: "use a for loop aswell as thetwod_to_onedfunction to make it into a temporary 2d array such that each element now has an i and j value assigned to it" - what do you mean by that? What do you mean by "temporary 2d array"? And what do you mean by "each element now has aniandjvalue assigned to it"?
– Fureeish
Dec 31 '18 at 17:22
I think it's clear now. One more thing - what isside?
– Fureeish
Dec 31 '18 at 17:26
add a comment |
this has been omitted. Does not follow rules.
c++ loops vector
this has been omitted. Does not follow rules.
c++ loops vector
c++ loops vector
edited Jan 10 at 13:20
James
asked Dec 31 '18 at 16:46
JamesJames
134
134
In the comment below you stated that you want to: "use a for loop aswell as thetwod_to_onedfunction to make it into a temporary 2d array such that each element now has an i and j value assigned to it" - what do you mean by that? What do you mean by "temporary 2d array"? And what do you mean by "each element now has aniandjvalue assigned to it"?
– Fureeish
Dec 31 '18 at 17:22
I think it's clear now. One more thing - what isside?
– Fureeish
Dec 31 '18 at 17:26
add a comment |
In the comment below you stated that you want to: "use a for loop aswell as thetwod_to_onedfunction to make it into a temporary 2d array such that each element now has an i and j value assigned to it" - what do you mean by that? What do you mean by "temporary 2d array"? And what do you mean by "each element now has aniandjvalue assigned to it"?
– Fureeish
Dec 31 '18 at 17:22
I think it's clear now. One more thing - what isside?
– Fureeish
Dec 31 '18 at 17:26
In the comment below you stated that you want to: "use a for loop aswell as the
twod_to_oned function to make it into a temporary 2d array such that each element now has an i and j value assigned to it" - what do you mean by that? What do you mean by "temporary 2d array"? And what do you mean by "each element now has an i and j value assigned to it"?– Fureeish
Dec 31 '18 at 17:22
In the comment below you stated that you want to: "use a for loop aswell as the
twod_to_oned function to make it into a temporary 2d array such that each element now has an i and j value assigned to it" - what do you mean by that? What do you mean by "temporary 2d array"? And what do you mean by "each element now has an i and j value assigned to it"?– Fureeish
Dec 31 '18 at 17:22
I think it's clear now. One more thing - what is
side?– Fureeish
Dec 31 '18 at 17:26
I think it's clear now. One more thing - what is
side?– Fureeish
Dec 31 '18 at 17:26
add a comment |
2 Answers
2
active
oldest
votes
takes in input a one dimensional vector
but
int rowlength = std::sqrt(in.size());
The line of code appears to assume that the input is actually a square two dimensional matrix ( i.e. same number of rows and columns ) So which is it? What if the number of elements in the in vector is not a perfect square?
This confusion about the input is likely to cuase your problem and should be sorted out before doing anything else.
How is that an answer, not a comment?
– Fureeish
Dec 31 '18 at 17:01
That's right. Such a type should be its own class with a vector, a width and a height (well, I suppose just one of the dimensions will suffice). Not just a vector, which does not provide sufficient information.
– Lightness Races in Orbit
Dec 31 '18 at 17:01
1
@Fureeish Because it is an explanation of the cause of the problem? Those do not go in the comments section. The comments section is for requesting clarification.
– Lightness Races in Orbit
Dec 31 '18 at 17:02
I would rather consider that a hint, if anything. The question states that the first loop should convert the input to 2D matrix (which itself is incorrect - it has undefined behaviour in form of accessing avectorout of bounds). Converting to 2D, at least for me, clearly states that the programmer is aware of the fact that the input was not originally a 2D array. It might be a flattened square matrix, which would make the quoted code absolutely correct
– Fureeish
Dec 31 '18 at 17:10
@James, so you would like to have the converted to 1D row, converted back to 2D? The goal seems a little unclear, since you appear to be trying to copy the flattened board to another 1Dstd::vector. Did you mean to have a so called 2D vector in form ofstd::vector<std::vector<int>>? That way you could access it by[i][j]syntax. Please clarify
– Fureeish
Dec 31 '18 at 17:15
add a comment |
I think what you wanted to do is the following:
void get_row(int r, const std::vector<int>& in, std::vector<int>& out) {
int rowlength = std::sqrt(in.size());
std::vector<std::vector<int>> temp; // now a 2D vector (vector of vectors)
for(int i = 0; i < rowlength; i++) {
temp.emplace_back(); // for each row, we need to emplace it
for(int j = 0; j < rowlength; j++) {
// we need to copy every value to the i-th row
temp[i].push_back(in[twod_to_oned(i, j, rowlength)]);
}
}
for(int j = 0; j < rowlength; j++) {
// we copy the r-th row to out
out.push_back(temp[r][j]);
}
}
Your solution used std::vector<int> instead of std::vector<std::vector<int>>. The former does not support accessing elements by syntax.
You were also assigning to that vector out of its bounds. That lead to undefined behaviour. Always use push_back or emplate_back to add elements. Use operator only to access the present data.
Lastly, the same holds true for inserting the row to out vector. Only you can know if the out vector holds enough elements. My solution assumes that out is empty, thus we need to push_back the entire row to it.
In addition: you might want to use std::vector::insert instead of manual for() loop. Consider replacing the third loop with:
out.insert(out.end(), temp[r].begin(), temp[r].end());
which may prove being more efficient and readable. The inner for() look of the first loop could also be replaced in such a way (or even better - one could emplace the vector using iterators obtained from the in vector). I highly advise you to try to implement that.
Long story short: emplacement creates an element inside the container, while pushing / inserting results in (sometimes) creating a temporary and copying it to the container. One should always consider using emplacement over insertion, but it's not always the case that it's better. A fairly good read. If you encounter the name "Scott Meyers" while maybe doing a little more research regarding this topic, you will likely find the best source
– Fureeish
Dec 31 '18 at 18:10
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53989638%2foutputting-a-row-of-a-vector%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
takes in input a one dimensional vector
but
int rowlength = std::sqrt(in.size());
The line of code appears to assume that the input is actually a square two dimensional matrix ( i.e. same number of rows and columns ) So which is it? What if the number of elements in the in vector is not a perfect square?
This confusion about the input is likely to cuase your problem and should be sorted out before doing anything else.
How is that an answer, not a comment?
– Fureeish
Dec 31 '18 at 17:01
That's right. Such a type should be its own class with a vector, a width and a height (well, I suppose just one of the dimensions will suffice). Not just a vector, which does not provide sufficient information.
– Lightness Races in Orbit
Dec 31 '18 at 17:01
1
@Fureeish Because it is an explanation of the cause of the problem? Those do not go in the comments section. The comments section is for requesting clarification.
– Lightness Races in Orbit
Dec 31 '18 at 17:02
I would rather consider that a hint, if anything. The question states that the first loop should convert the input to 2D matrix (which itself is incorrect - it has undefined behaviour in form of accessing avectorout of bounds). Converting to 2D, at least for me, clearly states that the programmer is aware of the fact that the input was not originally a 2D array. It might be a flattened square matrix, which would make the quoted code absolutely correct
– Fureeish
Dec 31 '18 at 17:10
@James, so you would like to have the converted to 1D row, converted back to 2D? The goal seems a little unclear, since you appear to be trying to copy the flattened board to another 1Dstd::vector. Did you mean to have a so called 2D vector in form ofstd::vector<std::vector<int>>? That way you could access it by[i][j]syntax. Please clarify
– Fureeish
Dec 31 '18 at 17:15
add a comment |
takes in input a one dimensional vector
but
int rowlength = std::sqrt(in.size());
The line of code appears to assume that the input is actually a square two dimensional matrix ( i.e. same number of rows and columns ) So which is it? What if the number of elements in the in vector is not a perfect square?
This confusion about the input is likely to cuase your problem and should be sorted out before doing anything else.
How is that an answer, not a comment?
– Fureeish
Dec 31 '18 at 17:01
That's right. Such a type should be its own class with a vector, a width and a height (well, I suppose just one of the dimensions will suffice). Not just a vector, which does not provide sufficient information.
– Lightness Races in Orbit
Dec 31 '18 at 17:01
1
@Fureeish Because it is an explanation of the cause of the problem? Those do not go in the comments section. The comments section is for requesting clarification.
– Lightness Races in Orbit
Dec 31 '18 at 17:02
I would rather consider that a hint, if anything. The question states that the first loop should convert the input to 2D matrix (which itself is incorrect - it has undefined behaviour in form of accessing avectorout of bounds). Converting to 2D, at least for me, clearly states that the programmer is aware of the fact that the input was not originally a 2D array. It might be a flattened square matrix, which would make the quoted code absolutely correct
– Fureeish
Dec 31 '18 at 17:10
@James, so you would like to have the converted to 1D row, converted back to 2D? The goal seems a little unclear, since you appear to be trying to copy the flattened board to another 1Dstd::vector. Did you mean to have a so called 2D vector in form ofstd::vector<std::vector<int>>? That way you could access it by[i][j]syntax. Please clarify
– Fureeish
Dec 31 '18 at 17:15
add a comment |
takes in input a one dimensional vector
but
int rowlength = std::sqrt(in.size());
The line of code appears to assume that the input is actually a square two dimensional matrix ( i.e. same number of rows and columns ) So which is it? What if the number of elements in the in vector is not a perfect square?
This confusion about the input is likely to cuase your problem and should be sorted out before doing anything else.
takes in input a one dimensional vector
but
int rowlength = std::sqrt(in.size());
The line of code appears to assume that the input is actually a square two dimensional matrix ( i.e. same number of rows and columns ) So which is it? What if the number of elements in the in vector is not a perfect square?
This confusion about the input is likely to cuase your problem and should be sorted out before doing anything else.
edited Dec 31 '18 at 17:03
answered Dec 31 '18 at 16:59
ravenspointravenspoint
12.8k44280
12.8k44280
How is that an answer, not a comment?
– Fureeish
Dec 31 '18 at 17:01
That's right. Such a type should be its own class with a vector, a width and a height (well, I suppose just one of the dimensions will suffice). Not just a vector, which does not provide sufficient information.
– Lightness Races in Orbit
Dec 31 '18 at 17:01
1
@Fureeish Because it is an explanation of the cause of the problem? Those do not go in the comments section. The comments section is for requesting clarification.
– Lightness Races in Orbit
Dec 31 '18 at 17:02
I would rather consider that a hint, if anything. The question states that the first loop should convert the input to 2D matrix (which itself is incorrect - it has undefined behaviour in form of accessing avectorout of bounds). Converting to 2D, at least for me, clearly states that the programmer is aware of the fact that the input was not originally a 2D array. It might be a flattened square matrix, which would make the quoted code absolutely correct
– Fureeish
Dec 31 '18 at 17:10
@James, so you would like to have the converted to 1D row, converted back to 2D? The goal seems a little unclear, since you appear to be trying to copy the flattened board to another 1Dstd::vector. Did you mean to have a so called 2D vector in form ofstd::vector<std::vector<int>>? That way you could access it by[i][j]syntax. Please clarify
– Fureeish
Dec 31 '18 at 17:15
add a comment |
How is that an answer, not a comment?
– Fureeish
Dec 31 '18 at 17:01
That's right. Such a type should be its own class with a vector, a width and a height (well, I suppose just one of the dimensions will suffice). Not just a vector, which does not provide sufficient information.
– Lightness Races in Orbit
Dec 31 '18 at 17:01
1
@Fureeish Because it is an explanation of the cause of the problem? Those do not go in the comments section. The comments section is for requesting clarification.
– Lightness Races in Orbit
Dec 31 '18 at 17:02
I would rather consider that a hint, if anything. The question states that the first loop should convert the input to 2D matrix (which itself is incorrect - it has undefined behaviour in form of accessing avectorout of bounds). Converting to 2D, at least for me, clearly states that the programmer is aware of the fact that the input was not originally a 2D array. It might be a flattened square matrix, which would make the quoted code absolutely correct
– Fureeish
Dec 31 '18 at 17:10
@James, so you would like to have the converted to 1D row, converted back to 2D? The goal seems a little unclear, since you appear to be trying to copy the flattened board to another 1Dstd::vector. Did you mean to have a so called 2D vector in form ofstd::vector<std::vector<int>>? That way you could access it by[i][j]syntax. Please clarify
– Fureeish
Dec 31 '18 at 17:15
How is that an answer, not a comment?
– Fureeish
Dec 31 '18 at 17:01
How is that an answer, not a comment?
– Fureeish
Dec 31 '18 at 17:01
That's right. Such a type should be its own class with a vector, a width and a height (well, I suppose just one of the dimensions will suffice). Not just a vector, which does not provide sufficient information.
– Lightness Races in Orbit
Dec 31 '18 at 17:01
That's right. Such a type should be its own class with a vector, a width and a height (well, I suppose just one of the dimensions will suffice). Not just a vector, which does not provide sufficient information.
– Lightness Races in Orbit
Dec 31 '18 at 17:01
1
1
@Fureeish Because it is an explanation of the cause of the problem? Those do not go in the comments section. The comments section is for requesting clarification.
– Lightness Races in Orbit
Dec 31 '18 at 17:02
@Fureeish Because it is an explanation of the cause of the problem? Those do not go in the comments section. The comments section is for requesting clarification.
– Lightness Races in Orbit
Dec 31 '18 at 17:02
I would rather consider that a hint, if anything. The question states that the first loop should convert the input to 2D matrix (which itself is incorrect - it has undefined behaviour in form of accessing a
vector out of bounds). Converting to 2D, at least for me, clearly states that the programmer is aware of the fact that the input was not originally a 2D array. It might be a flattened square matrix, which would make the quoted code absolutely correct– Fureeish
Dec 31 '18 at 17:10
I would rather consider that a hint, if anything. The question states that the first loop should convert the input to 2D matrix (which itself is incorrect - it has undefined behaviour in form of accessing a
vector out of bounds). Converting to 2D, at least for me, clearly states that the programmer is aware of the fact that the input was not originally a 2D array. It might be a flattened square matrix, which would make the quoted code absolutely correct– Fureeish
Dec 31 '18 at 17:10
@James, so you would like to have the converted to 1D row, converted back to 2D? The goal seems a little unclear, since you appear to be trying to copy the flattened board to another 1D
std::vector. Did you mean to have a so called 2D vector in form of std::vector<std::vector<int>>? That way you could access it by [i][j] syntax. Please clarify– Fureeish
Dec 31 '18 at 17:15
@James, so you would like to have the converted to 1D row, converted back to 2D? The goal seems a little unclear, since you appear to be trying to copy the flattened board to another 1D
std::vector. Did you mean to have a so called 2D vector in form of std::vector<std::vector<int>>? That way you could access it by [i][j] syntax. Please clarify– Fureeish
Dec 31 '18 at 17:15
add a comment |
I think what you wanted to do is the following:
void get_row(int r, const std::vector<int>& in, std::vector<int>& out) {
int rowlength = std::sqrt(in.size());
std::vector<std::vector<int>> temp; // now a 2D vector (vector of vectors)
for(int i = 0; i < rowlength; i++) {
temp.emplace_back(); // for each row, we need to emplace it
for(int j = 0; j < rowlength; j++) {
// we need to copy every value to the i-th row
temp[i].push_back(in[twod_to_oned(i, j, rowlength)]);
}
}
for(int j = 0; j < rowlength; j++) {
// we copy the r-th row to out
out.push_back(temp[r][j]);
}
}
Your solution used std::vector<int> instead of std::vector<std::vector<int>>. The former does not support accessing elements by syntax.
You were also assigning to that vector out of its bounds. That lead to undefined behaviour. Always use push_back or emplate_back to add elements. Use operator only to access the present data.
Lastly, the same holds true for inserting the row to out vector. Only you can know if the out vector holds enough elements. My solution assumes that out is empty, thus we need to push_back the entire row to it.
In addition: you might want to use std::vector::insert instead of manual for() loop. Consider replacing the third loop with:
out.insert(out.end(), temp[r].begin(), temp[r].end());
which may prove being more efficient and readable. The inner for() look of the first loop could also be replaced in such a way (or even better - one could emplace the vector using iterators obtained from the in vector). I highly advise you to try to implement that.
Long story short: emplacement creates an element inside the container, while pushing / inserting results in (sometimes) creating a temporary and copying it to the container. One should always consider using emplacement over insertion, but it's not always the case that it's better. A fairly good read. If you encounter the name "Scott Meyers" while maybe doing a little more research regarding this topic, you will likely find the best source
– Fureeish
Dec 31 '18 at 18:10
add a comment |
I think what you wanted to do is the following:
void get_row(int r, const std::vector<int>& in, std::vector<int>& out) {
int rowlength = std::sqrt(in.size());
std::vector<std::vector<int>> temp; // now a 2D vector (vector of vectors)
for(int i = 0; i < rowlength; i++) {
temp.emplace_back(); // for each row, we need to emplace it
for(int j = 0; j < rowlength; j++) {
// we need to copy every value to the i-th row
temp[i].push_back(in[twod_to_oned(i, j, rowlength)]);
}
}
for(int j = 0; j < rowlength; j++) {
// we copy the r-th row to out
out.push_back(temp[r][j]);
}
}
Your solution used std::vector<int> instead of std::vector<std::vector<int>>. The former does not support accessing elements by syntax.
You were also assigning to that vector out of its bounds. That lead to undefined behaviour. Always use push_back or emplate_back to add elements. Use operator only to access the present data.
Lastly, the same holds true for inserting the row to out vector. Only you can know if the out vector holds enough elements. My solution assumes that out is empty, thus we need to push_back the entire row to it.
In addition: you might want to use std::vector::insert instead of manual for() loop. Consider replacing the third loop with:
out.insert(out.end(), temp[r].begin(), temp[r].end());
which may prove being more efficient and readable. The inner for() look of the first loop could also be replaced in such a way (or even better - one could emplace the vector using iterators obtained from the in vector). I highly advise you to try to implement that.
Long story short: emplacement creates an element inside the container, while pushing / inserting results in (sometimes) creating a temporary and copying it to the container. One should always consider using emplacement over insertion, but it's not always the case that it's better. A fairly good read. If you encounter the name "Scott Meyers" while maybe doing a little more research regarding this topic, you will likely find the best source
– Fureeish
Dec 31 '18 at 18:10
add a comment |
I think what you wanted to do is the following:
void get_row(int r, const std::vector<int>& in, std::vector<int>& out) {
int rowlength = std::sqrt(in.size());
std::vector<std::vector<int>> temp; // now a 2D vector (vector of vectors)
for(int i = 0; i < rowlength; i++) {
temp.emplace_back(); // for each row, we need to emplace it
for(int j = 0; j < rowlength; j++) {
// we need to copy every value to the i-th row
temp[i].push_back(in[twod_to_oned(i, j, rowlength)]);
}
}
for(int j = 0; j < rowlength; j++) {
// we copy the r-th row to out
out.push_back(temp[r][j]);
}
}
Your solution used std::vector<int> instead of std::vector<std::vector<int>>. The former does not support accessing elements by syntax.
You were also assigning to that vector out of its bounds. That lead to undefined behaviour. Always use push_back or emplate_back to add elements. Use operator only to access the present data.
Lastly, the same holds true for inserting the row to out vector. Only you can know if the out vector holds enough elements. My solution assumes that out is empty, thus we need to push_back the entire row to it.
In addition: you might want to use std::vector::insert instead of manual for() loop. Consider replacing the third loop with:
out.insert(out.end(), temp[r].begin(), temp[r].end());
which may prove being more efficient and readable. The inner for() look of the first loop could also be replaced in such a way (or even better - one could emplace the vector using iterators obtained from the in vector). I highly advise you to try to implement that.
I think what you wanted to do is the following:
void get_row(int r, const std::vector<int>& in, std::vector<int>& out) {
int rowlength = std::sqrt(in.size());
std::vector<std::vector<int>> temp; // now a 2D vector (vector of vectors)
for(int i = 0; i < rowlength; i++) {
temp.emplace_back(); // for each row, we need to emplace it
for(int j = 0; j < rowlength; j++) {
// we need to copy every value to the i-th row
temp[i].push_back(in[twod_to_oned(i, j, rowlength)]);
}
}
for(int j = 0; j < rowlength; j++) {
// we copy the r-th row to out
out.push_back(temp[r][j]);
}
}
Your solution used std::vector<int> instead of std::vector<std::vector<int>>. The former does not support accessing elements by syntax.
You were also assigning to that vector out of its bounds. That lead to undefined behaviour. Always use push_back or emplate_back to add elements. Use operator only to access the present data.
Lastly, the same holds true for inserting the row to out vector. Only you can know if the out vector holds enough elements. My solution assumes that out is empty, thus we need to push_back the entire row to it.
In addition: you might want to use std::vector::insert instead of manual for() loop. Consider replacing the third loop with:
out.insert(out.end(), temp[r].begin(), temp[r].end());
which may prove being more efficient and readable. The inner for() look of the first loop could also be replaced in such a way (or even better - one could emplace the vector using iterators obtained from the in vector). I highly advise you to try to implement that.
edited Jan 1 at 12:34
answered Dec 31 '18 at 17:39
FureeishFureeish
3,41321029
3,41321029
Long story short: emplacement creates an element inside the container, while pushing / inserting results in (sometimes) creating a temporary and copying it to the container. One should always consider using emplacement over insertion, but it's not always the case that it's better. A fairly good read. If you encounter the name "Scott Meyers" while maybe doing a little more research regarding this topic, you will likely find the best source
– Fureeish
Dec 31 '18 at 18:10
add a comment |
Long story short: emplacement creates an element inside the container, while pushing / inserting results in (sometimes) creating a temporary and copying it to the container. One should always consider using emplacement over insertion, but it's not always the case that it's better. A fairly good read. If you encounter the name "Scott Meyers" while maybe doing a little more research regarding this topic, you will likely find the best source
– Fureeish
Dec 31 '18 at 18:10
Long story short: emplacement creates an element inside the container, while pushing / inserting results in (sometimes) creating a temporary and copying it to the container. One should always consider using emplacement over insertion, but it's not always the case that it's better. A fairly good read. If you encounter the name "Scott Meyers" while maybe doing a little more research regarding this topic, you will likely find the best source
– Fureeish
Dec 31 '18 at 18:10
Long story short: emplacement creates an element inside the container, while pushing / inserting results in (sometimes) creating a temporary and copying it to the container. One should always consider using emplacement over insertion, but it's not always the case that it's better. A fairly good read. If you encounter the name "Scott Meyers" while maybe doing a little more research regarding this topic, you will likely find the best source
– Fureeish
Dec 31 '18 at 18:10
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53989638%2foutputting-a-row-of-a-vector%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
In the comment below you stated that you want to: "use a for loop aswell as the
twod_to_onedfunction to make it into a temporary 2d array such that each element now has an i and j value assigned to it" - what do you mean by that? What do you mean by "temporary 2d array"? And what do you mean by "each element now has aniandjvalue assigned to it"?– Fureeish
Dec 31 '18 at 17:22
I think it's clear now. One more thing - what is
side?– Fureeish
Dec 31 '18 at 17:26