Open devLupin opened 1 year ago
swap_ranges
first1
, last1
) and another range starting at first2
.first1
, last1
: the first range of elements to swapfirst2
: beginning of the second range of elements to swaplast1
이 주어지면 last2
는 굳이 필요없음.// example
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int a[5] = {1, 2, 3, 4, 5};
int b[5] = {6, 7, 8, 9, 10};
swap_ranges(a, a+3, b);
cout << "a:";
for(int i=0; i<5; i++) cout << ' ' << a[i];
cout << endl << "b:";
for(int i=0; i<5; i++) cout << ' ' << b[i];
cout << endl;
return 0;
}
swap
a
andb
template <class T> void swap (T& a, T& b)