Cadernos de Questões

Provas Favoritas

Filtros Salvos

Foram encontradas 70 questões.
#2701359

public class Teste {

       public static void main(String args[]) {

              System.out.println("Saida:");

              xyz(5, 0);

        }

        static int xyz(int n, int m) {

              int i;

              for (i = 0; i < m; ++i) {

                   System.out.println(" " + i + " ");

              }

             System.out.println("xyz(" + n + "," + m + ")");

              if (n == 1) {

                   return 1;

               }

               if (n % 2 == 0) {

                    return xyz(n / 2, m + 1);

                }

                return xyz((n - 1) / 2, m + 1) + xyz((n + 1) / 2, m + 1);

        }

}

O resultado do código apresentado é

  • Saida:xyz(5,0)xyz(2,1)xyz(1,2)xyz(3,1)xyz(1,2)xyz(2,2)xyz(1,3)
  • Saida:xyz(1,3)xyz(2,2)xyz(1,2)xyz(3,1)xyz(1,2)xyz(2,1)xyz(5,0)
  • Saida:xyz(5,0)01xyz(5,0)012xyz(5,0)
  • Saida:xyz(5,0)0xyz(2,1)0 1xyz(1,2)0xyz(3,1)0 1xyz(1,2)0 1xyz(2,2)0 1 2xyz(1,3)
  • Saida:0 0 1 0 0 1 0 1 0 1 2
Fale com IAgo
IAgo - Assistente IAProva
IA
Olá! Sou o IAgo, seu assistente aqui no IAProvatec 😊
Veja como posso te ajudar:
Agora