/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ud2ejerc38;
/**
*
* @author Juan
*/
public class Ud2Ejerc38 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int num=99, unid, dec, cent;
do {num=num+1;
cent=num/100;
dec=num/10-cent*10;
unid=num-cent*100-dec*10;
if (num==Math.pow(cent,3)+Math.pow(dec,3)+Math.pow(unid,3)) System.out.printf("%d \t", num);
} while (num!=999);
// TODO code application logic here
for (int i = 100; i < 1000; i++) {
if (i==(Math.pow(i/100, 3)+Math.pow((i%100)/10,3)+Math.pow(i%10,3))) {
System.out.print(" "+i);
}
}System.out.println();
for (int x = 1; x < 10; x++) {
for (int y = 0; y < 10; y++) {
for (int z = 0; z < 10; z++) {
num= x*100+y*10+z;
if (num==(Math.pow(x, 3)+Math.pow(y,3)+Math.pow(z,3))) {
System.out.println(" "+num);
}
}
}
}
}
}
Resto ejercicios:
http://tecnoloxiaxa.blogspot.com.es/2013/09/dam-programacion.html
No hay comentarios:
Publicar un comentario