#include <iostream>
#include <string>
using namespace std;
template<typename T>
void reverseArray(T *arr,int size) {
T *swap;
for (int i=0;i<size/2;i++) {
swap=new T [size];
swap[i]=arr[i];
arr[i]=arr[size-1-i];
arr[size-1-i]=swap[i];
}
}
template<typename F>
void printArray(F *arr,int size) {
for (int i=0;i<size;i++) {
cout<<arr[i]<<" ";
}
cout<<endl;
}
int main() {
int arr[]={1,2,3,4};
reverseArray(arr,4);
printArray(arr,4);
double arrd[]={3.08,4.72,2.00,3.21,10.90};
reverseArray(arrd,5);
printArray(arrd,5);
char letter[]={'2','D','w'};
reverseArray(letter,3);
printArray(letter,3);
string text[]={"hello world","kitten"};
reverseArray(text,2);
printArray(text,2);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0ZW1wbGF0ZTx0eXBlbmFtZSBUPgp2b2lkIHJldmVyc2VBcnJheShUICphcnIsaW50IHNpemUpIHsKCVQgKnN3YXA7CiAgICBmb3IgKGludCBpPTA7aTxzaXplLzI7aSsrKSB7CiAgICAgICAgc3dhcD1uZXcgVCBbc2l6ZV07CiAgICAgICAgc3dhcFtpXT1hcnJbaV07CiAgICAgICAgYXJyW2ldPWFycltzaXplLTEtaV07CiAgICAgICAgYXJyW3NpemUtMS1pXT1zd2FwW2ldOwogICAgfQp9CnRlbXBsYXRlPHR5cGVuYW1lIEY+CnZvaWQgcHJpbnRBcnJheShGICphcnIsaW50IHNpemUpIHsKCWZvciAoaW50IGk9MDtpPHNpemU7aSsrKSB7CgkJY291dDw8YXJyW2ldPDwiICI7Cgl9Cgljb3V0PDxlbmRsOwp9CmludCBtYWluKCkgewoJaW50IGFycltdPXsxLDIsMyw0fTsKICAgIHJldmVyc2VBcnJheShhcnIsNCk7CiAgICBwcmludEFycmF5KGFyciw0KTsKICAgIGRvdWJsZSBhcnJkW109ezMuMDgsNC43MiwyLjAwLDMuMjEsMTAuOTB9OwogICAgcmV2ZXJzZUFycmF5KGFycmQsNSk7CiAgICBwcmludEFycmF5KGFycmQsNSk7CiAgICBjaGFyIGxldHRlcltdPXsnMicsJ0QnLCd3J307CiAgICByZXZlcnNlQXJyYXkobGV0dGVyLDMpOwogICAgcHJpbnRBcnJheShsZXR0ZXIsMyk7CiAgICBzdHJpbmcgdGV4dFtdPXsiaGVsbG8gd29ybGQiLCJraXR0ZW4ifTsKICAgIHJldmVyc2VBcnJheSh0ZXh0LDIpOwogICAgcHJpbnRBcnJheSh0ZXh0LDIpOwoJcmV0dXJuIDA7Cn0=