Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Função recursiva que mostre o maior elemento de um vetor.
- class Inicio{
- public static void main(String[] args) {
- int[] a = {5, 5, 8, 9, 6};
- int maior = array(a, (a.length - 1), a[a.length - 1]);
- System.out.println("O maior é " + maior);
- }
- public static int array(int[] b, int num, int maior){
- if(num >= 0){
- if(b[num] > maior){
- maior = b[num];
- }
- return array(b, num - 1, maior);
- }
- return maior;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement