Skip to content

Instantly share code, notes, and snippets.

@sam43
Created March 12, 2019 19:42
Show Gist options
  • Save sam43/8102a1bbcea3758bcbf7979c6c43cfc4 to your computer and use it in GitHub Desktop.
Save sam43/8102a1bbcea3758bcbf7979c6c43cfc4 to your computer and use it in GitHub Desktop.
static void reverse(int a[], int n)
{
int i, k, t;
for (i = 0; i < n / 2; i++) {
t = a[i];
a[i] = a[n - i - 1];
a[n - i - 1] = t;
}
/*printing the reversed array*/
//System.out.println("Reversed array is: \n");
for (k = 0; k < n; k++) {
System.out.print(a[k]+" ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment