水仙花数是三位数,它的各位数字的立方和等于这个三位数本身,例如:371=33+73+13,371就是一个水仙花数. 要判断是否是水仙花数,首先得得到它的每一位上的数.个位数即为对10取余:十位数为对100取余减去个位数再除以10,百位数为减去对100取余后的数再除以100. 代码如下: public class shuixianhua { public static void main(String args[]){ int x=100; int a,b,c; while(x<=999){ a=…
题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身.例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方. 程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位. 程序源代码: #!/usr/bin/python # -*- coding: UTF-8 -*- for n in range(100, 1000): i = n / 100 j = n / 1…
/* 在控制台输出所有的“水仙花数” 水仙花:100-999 在以上数字范围内:这个数=个位*个位*个位+十位*十位*十位+百位*百位*百位 例如:xyz=x^3 +y^3 +z^3 怎么把三位数字拆成每位整数 思路:百位: int x= i / 100 十位: int y = i / 10 % 10 个位: int z = i % 10 */ class LoopTest3 { public static void main(String[] args) { for (int i=100; i…
水仙花数是指一个 n 位数 ( n>=3 ),它的每个位上的数字的 n 次幂之和等于它本身.(例如:1^3 + 5^3 + 3^3 = 153) 三位的水仙花数共有4个,分别为:153.370.371.407 代码实现: public class For_Demo2 { public static void main(String[] args) { //求水仙花数 int ge,shi,bai; int m=0; int total=0; for(int i=100;i<1000;i++){…
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script type="text/javascript"> var num = []; var j = 0; for(var i = 100; i < 1000; i ++){ var iG,…
public class Three_03 { public static void main(String[] args) { for(int i=100;i<1000;i++){ int a=i%10; int b=i/10%10; int c=i/100; if((a*a*a+b*b*b+c*c*c)==i){ System.out.println(i); }else{ continue; } } }}…
Description Have you played Draw Something? It's currently one of the hottest social drawing games on Apple iOS and Android Devices! In this game, you and your friend play in turn. You need to pick a word and draw a picture for this word. Then your f…
package printDaffodilNumber; /* * 题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身.(100~1000) * 比如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方. */ public class printNumber { static int number1; static int number2; static int number3;…