include iostream include string using namespace std void reverse int a

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <string.h>
using namespace std;
void reverse(int *arr, size_t size) {
int *array = arr + size - 1;
int temp;
while (arr < array) {
temp = *arr;
*arr = *array;
*array = temp;
--array;
++arr;
}
}
int main() {
cout << "Enter dimension of the array:" << endl;
size_t dimension;
cin >> dimension;
int array[dimension];
for (int i = 0; i < dimension; ++i) {
cout << "Enter array[" << i << "]" << endl;
cin >> array[i];
}
cout << "Entered array: " << endl;
for (int i = 0; i < dimension; ++i) {
cout << array[i];
}
reverse(array, dimension);
cout << endl << "Reversed array: " << endl;
for (int i = 0; i < dimension; ++i) {
cout << array[i];
}
return 0;
}