水仙花代码
//求0~999水仙花数并输出 private static void Narnumber() { int i,j,k,num; System.out.println("0~999水仙花数为:"); for (i=0;i <= 9;i++){ for (j=0; j <= 9;j++){ for (k=0;k <= 9;k++){ num = (i*100) + (j*10) + k; if (Math.pow(i,3) + Math.pow(j,3) + Math.pow(k,3) == num && num >= 100){ System.out.print(num + "\t"); } } } } }
本文来自博客园,作者:xiaoyongdata(微信号:xiaoyongdata),转载请注明原文链接:https://www.cnblogs.com/xiaoyongdata/p/16267454.html