Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.36 KB | None | 0 0
  1. public static void ex2(int[] a) {
  2.     if (a != null && a.length > 0) {
  3.         sovrascrive(a, 0, a.length);
  4.     }
  5. }
  6.  
  7. private static void sovrascrive(int[] a, int s, int d) {
  8.     if (s < d) {
  9.         if (s + 1 == d) {
  10.             if (s % 2 == 0 && s + 1 < a.length) {
  11.                 a[s] = a[s + 1];
  12.             }
  13.         } else {
  14.             sovrascrive(a, s, (s + d) / 2); sovrascrive(a, (s + d) / 2, d);
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement