水仙花数
来源:互联网 发布:淘宝小样 编辑:程序博客网 时间:2024/03/29 03:17
public class DaffodilNum{
private int n;
public DaffodilNum(int n){
this.n=n;
}
public boolean IsOrNot(){
int a=n%10;
int b=(n%100-a)/10;
int c=(n-b*10-a)/100;
if((Math.pow(a,3)+Math.pow(b,3)+Math.pow(c,3))==n) return true;
return false;
}
public static void main(String[] args){
for(int i=0;i<1000;i++){
DaffodilNum temp=new DaffodilNum(i);
if(temp.IsOrNot()) System.out.print(i+" ");
}
System.out.println();
}
}
private int n;
public DaffodilNum(int n){
this.n=n;
}
public boolean IsOrNot(){
int a=n%10;
int b=(n%100-a)/10;
int c=(n-b*10-a)/100;
if((Math.pow(a,3)+Math.pow(b,3)+Math.pow(c,3))==n) return true;
return false;
}
public static void main(String[] args){
for(int i=0;i<1000;i++){
DaffodilNum temp=new DaffodilNum(i);
if(temp.IsOrNot()) System.out.print(i+" ");
}
System.out.println();
}
}
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 认识ASP.NET配置文件Web.config
- 素数_判断是否素数
- &&情侣开房记&&
- System.Messaging 性能
- 永远的beyond~
- 水仙花数
- JBossIDE Eclispe 开发EJB2.1实例[原创]
- 如何在MSN Space 中添加Windows Media Player 播放模块
- ofs其他地方无法访问数据库
- C/C++中的日期和时间
- 使用gethostbyaddr,通过ip地址,得到该ip地址的主机的信息
- 使用gethostname()得到主机名
- 使用uname()得到主机名
- HiveMind初探