#include<iostream>
using namespace std;
void reverse(int arr[], int n, int s, int e) {
if (s > e) {
return;
}
swap(arr[s], arr[e]);
s++;
e--;
for (int i = 0; i < n; i++) {
cout << arr[i]<<" ";
}
cout<<endl;
reverse(arr, n, s, e);
}
int main() {
int arr[6] = { 1,2,3,4,5,6 };
int s = 0;
int e = sizeof(arr)/sizeof(arr[0])-1;
int n =sizeof(arr)/sizeof(arr[0]);
reverse(arr, n, s, e);
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter