123456789101112131415161718192021222324252627
#include <iostream> using namespace std; int main() { int a[] = {1,2,3,4,5}; int b[] = {6,7,8,9,10}; int c[10]; for(int i=0; i<5; i++) { c[i] = a[i]; } for(int i=5; i<10; i++) { c[i] = b[i-5]; } for(int i=0; i<10; i++) { cout << c[i] << endl; } }
123
auto i = copy( a, a + 5, c ); copy( b, b + 5, i );
12345
copy( b, b + 5, copy( a, a + 5, c ) );