java小练习(3)--水仙花 problem
<script src="http://scarky.com/widget/get/P9279E8F/" type="text/javascript"></script>
public class Main {
/**
* @param args the command line arguments
*/
static boolean is_ok(int i)
{
int d1,d2,d3,d4;
d1=i%10;
d2=(i/10)%10;
d3=(i/100)%10;
d4=(i/1000)%10;
if(i==d1*d1*d1*d1+d2*d2*d2*d2+d3*d3*d3*d3+d4*d4*d4*d4) return true;
else return false;
}
public static void main(String[] args) {
// TODO code application logic here
int i;
for(i=1000;i<10000;i++)
{
if(is_ok(i)) System.out.println(i);
}
}
}