Answer the question
In order to leave comments, you need to log in
By what principle are numbers displayed (back_inserter, front_inserter)?
I just can’t understand why 3 2 1 7 8 9 is displayed with back_inserter, and 7 8 9 1 2 3 with front_inserter? Do I understand correctly that the LIFO principle applies here? Then why does front_inserter print 1 2 3 at the end, and not 3 2 1, as in the first option?
int main()
{
setlocale(LC_ALL, "Russian");
deque<int> d1, d2;
int arr1[] = { 1, 2, 3 };
int arr2[] = { 7, 8, 9 };
for (int j = 0; j < 3; j++)
{
d1.push_back(arr1[j]);
d2.push_back(arr2[j]);
}
copy(d1.begin(), d1.end(), back_inserter(d2)); // или front_inserter(d2)
for (int j = 0; j < d2.size(); j++)
cout << d2[j] << ' ';
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question