java 打印100-1000之内的水仙花数

java 打印100-1000之内的水仙花数

“水仙花数”是指一个三位数,其各位数字的立方和确好等于该数本身,如;153=1+5+3?,则153是一个“水仙花数”。

机翻英语 : 

Java prints daffodils in the range of 100-1000  

A "daffodil number" is a three-digit number whose cube sum is exactly equal to the number itself, e.g.  153 = 1 + 5 + 3?  , 153 is a "daffodil number".  

/ * *  

/**
 * Project Name: One
 * File Name: One
 *
 * @version 1.0
 * @author:wenerduo
 * @Date: 2022/03/20/下午 12:12
 * Copyright (c) 2022,
 */
public class One {

        public static void main(String[] args) {

            int a,b,c;
            for(int i= 101; i < 1000; i++){
                    a = i/100;
                b = i%100/10;
                c = i%10;

                if((a*a*a + b*b*b + c*c*c) == i) {
                    System.out.println(i+"是一个水仙花数"); }
            }

        }

    }

你可能感兴趣的:(java,算法,刷题,java)