欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

水仙花数

程序员文章站 2024-03-17 16:35:16
...

用Java实现输出水仙花数

package edu.nynu.chapter01;
public class Flower {
	public static void main(String[]args){
		for(int i=100;i<999;i++){
			int a,b,c;
			a=i/100;
			b=i%100/10;
			c=i%10;
			if(i==a*a*a+b*b*b+c*c*c){
				System.out.print(i+"\t");
			}
			
		}
		//System.out.println("\n程序结束");
	}
}