http://www.cplusplus.com/reference/algorithm/merge/
int main () {
int first[] = {1, 3, 5, 7, 9};
int second[] = {2, 4, 6, 8, 10};
std::vector<int> v(10);
std::merge (first,first+5,second,second+5,v.begin());
std::cout << "The resulting vector contains:";
for (std::vector<int>::iterator it=v.begin(); it!=v.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}
int main () {
int first[] = {1, 3, 5, 7, 9};
int second[] = {2, 4, 6, 8, 10};
std::vector<int> v(10);
std::merge (first,first+5,second,second+5,v.begin());
std::cout << "The resulting vector contains:";
for (std::vector<int>::iterator it=v.begin(); it!=v.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}
Комментариев нет:
Отправить комментарий