• This is default featured slide 1 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by NewBloggerThemes.com.

  • This is default featured slide 2 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by NewBloggerThemes.com.

  • This is default featured slide 3 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by NewBloggerThemes.com.

  • This is default featured slide 4 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by NewBloggerThemes.com.

  • This is default featured slide 5 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by NewBloggerThemes.com.

Mostrando entradas con la etiqueta aleatorio. Mostrar todas las entradas
Mostrando entradas con la etiqueta aleatorio. Mostrar todas las entradas

Capicua


Capicua es un numero que al voltearlo es el mismo ejemplo 121; 12521, etc.
Hagamos un programa que nos encuentre estos numeros.
/*
/*
 * Realizar el programa que asigne aleatoriamente el numero entero entre
 * 3 y 5 cifras , se pide calcular e imprimir cuantos nùmeros asignados
 *son capicuas
 */
public class capicua{

    public static void main(String[] args) {
        int n, num, i, cif, x, inv, cont;
        n = (int) (Math.random() * 100); // veces a repetir
        for (i = 0; i < n; i++) {
            num = (int) (Math.random() * 99900 + 100);
            x = num;
            inv = 0;
            cont = 0;
            do {
                cif = num % 10;// obtener ultima cifra
                inv = inv * 10 + cif; //invirtiendo el numero
                num = num / 10; //Quitandole la ultima cifra
            } while (num != 0);

            if (inv == x) {
                cont++;
                System.out.println(x + " es capicua");
            }
            else {
                System.out.println(x + " no es capicua");
            }
        }
    }
}
Link = http://www.mediafire.com/?utywdineju1
Share:

Visitantes

Flag Counter

Popular Posts

Etiquetas

Recent Posts