Created
April 28, 2021 11:28
-
-
Save syedjafer/b09b93246b2b5abf1b7329947a28873d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ReverseNum{ | |
| static void rvereseArray(int arr[], int start, int end) | |
| { | |
| int temp; | |
| if (start >= end) | |
| return; | |
| temp = arr[start]; | |
| arr[start] = arr[end]; | |
| arr[end] = temp; | |
| rvereseArray(arr, start+1, end-1); | |
| } | |
| static void printArray(int arr[], int size) | |
| { | |
| for (int i=0; i < size; i++) | |
| System.out.print(arr[i] + " "); | |
| System.out.println(""); | |
| } | |
| public static void main (String[] args) { | |
| int arr[] = {1, 2, 3, 4, 5, 6}; | |
| printArray(arr, 6); | |
| rvereseArray(arr, 0, 5); | |
| System.out.println("Reversed array is "); | |
| printArray(arr, 6); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment