标签:blog java 2014 for har file
/** * 水仙花数 * */ public class Daffodil { public static void main(String[] args) { int max = 9999 ; int min = 10 ; for(int x=min;x<max;x++){ String temp = String.valueOf( x ) ; int pow = temp.length() ; char[] chars = temp.toCharArray() ; int all = 0 ; for(char c : chars){ int a = Integer.parseInt( String.valueOf(c) ) ; all += Math.pow( a , pow ) ; } if(all == x){ System.out.println( x + "是水仙花数" ) ; } } } }
标签:blog java 2014 for har file
原文地址:http://blog.csdn.net/hfmbook/article/details/36016165