Search code snippets, questions, articles...

contador que va de 0 a 5 factorizado

import java.util.Arrays;
public class App {

    public static boolean todo10(int[] digito) {

        final int DUR = 10;

        if (digito[0] < DUR && digito[1] < DUR && digito[2] < DUR && digito[3] < DUR && digito[4] < DUR) {
            return true;
        } else {
            return false;
        }

    }

    public static boolean es10(int digito) {

        if (digito == 10){
            return true;
        }
        else{
            return false;
        }

    }

    public static void print_digitos(int[] digito) {

        System.out.println(Arrays.toString(digito));

    }

    public static void main(String[] args) {

        final int TAM = 5;
        int[] digito = new int[TAM];
        System.out.println(digito[1]);

        while (todo10(digito)) {

            print_digitos(digito);
            digito[4]++;
            for (int i = digito.length - 1; i > 0; i--) {
                if(es10(digito[i])){
                    digito[i-1]++;
                    digito[i]=0;
                }

            }

        }

    }
}
Was this helpful?
0 Comments