Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cassert>
- #include <vector>
- template <typename T>
- void ReverseArray(T* start, size_t size) {
- int i_2 = size-1;
- for(int i=0; i<i_2; i++){
- T helper = *(i+start);
- *(i+start)= *(i_2+start);
- *(i_2+start)= helper;
- i_2--;
- }
- }
- int main() {
- using namespace std;
- vector<int> v = {1, 2};
- ReverseArray(v.data(), v.size());
- assert(v == (vector<int>{2, 1}));
- }
Advertisement
Add Comment
Please, Sign In to add comment