Created
October 26, 2017 16:17
-
-
Save Tekaichi/defb23425f83eb7adfbac3bebe6542c2 to your computer and use it in GitHub Desktop.
RECURSIVE EXERCICIOS
This file contains 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
private static void recSeparate(int[] v, int i, List<Integer> list, int threshold) { | |
if(i == v.length){ | |
return; | |
} | |
if(v[i] < threshold){ | |
recSeparate(v,i+1,list,threshold); | |
list.addFirst( v[i]); | |
}else{ | |
list.addLast(v[i]); | |
recSeparate(v,++i,list,threshold); | |
} | |
} | |
public static int countDigit(int n, int digit) { | |
if ((n % 10) == digit) { | |
return 1 + countDigit(n / 10, digit); | |
} else if (n / 10 != 0) { | |
return countDigit(n / 10, digit); | |
} else { | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment