Last active
January 12, 2019 19:06
-
-
Save powext/d3df989cdc0c263829c773a906b56dfc to your computer and use it in GitHub Desktop.
exDue 1 Gennaio 2019
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 static int exDue(int[] a){ | |
int result = 0; | |
if(a!=null&&a.length!=0){ | |
result = exDueRic(a, 0, a.length-1); | |
} else { | |
return 0; | |
} | |
System.out.println(result); | |
return result; | |
} | |
public static int exDueRic(int[] a, int l, int r){ | |
int result = 0; | |
if(l>=r){ | |
if(testUno(a[l])&&!testDue(a[l])){ | |
result+=a[l]; | |
} else if(!testUno(a[l])&&testDue(a[l])){ | |
result+=a[l]; | |
} | |
} else { | |
int m = (r-l)/2; | |
result += exDueRic(a, l, m); | |
result += exDueRic(a, m+1, r); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment