Reverse Array Recursively 2015-07-20 ProgrammingAlgorithm Programming Source code12345678910111213141516171819202122232425262728293031323334353637#include <iostream>using namespace std;void reverse(int *A, int N, int i, int j){ // base case if(i >= j) return; // swap int t = A[i]; A[i] = A[j]; A[j] = t; // recursive reverse(A, N, ++i, --j);}void reverse(int *A, int N){ reverse(A, N, 0, N-1);}int main() { // your code goes here int A[5] = {1, 2, 3, 4, 5}; reverse(A, 5); for(int i = 0; i < 5; i++) { cout << A[i] << ","; } cout << endl; return 0;} Newer Back to High School Physics Older 베테랑