水仙花數(shù)是指一個?n?位數(shù)?(?n≥3?),它的每個位上的數(shù)字的?n?次冪之和等于它本身。(例如:1^3?+?5^3+?3^3?=?153)

創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),乳山企業(yè)網(wǎng)站建設(shè),乳山品牌網(wǎng)站建設(shè),網(wǎng)站定制,乳山網(wǎng)站建設(shè)報(bào)價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,乳山網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
public class Daffodil {
/**
*
* @param
* @return void
* @param args
* desc
*/
public static void main(String[] args) {
for (int n = 100; n 999; n++) {
int a = n / 100;
int b = (n % 100) / 10;
int c = n % 10;
if(Math.pow(a, 3)+Math.pow(b,3)+Math.pow(c,3)==n){
System.out.println(n);
}
}
}
}
按一下代碼執(zhí)行:
public class woo {
public static void main(String args[]) {
System.out.println("100-1000中的水仙花數(shù)有:");
for(int i=100;i1000;i++){
int single? = i%10;
int ten = i/10%10;
int hundred = i/10/10%10;
//水仙花數(shù)判斷要求
if(i == (single*single*single+ten*ten*ten+hundred*hundred*hundred)){
System.out.println(i);
}
}
}
}
擴(kuò)展資料:
水仙花數(shù)只是自冪數(shù)的一種,嚴(yán)格來說3位數(shù)的3次冪數(shù)才稱為水仙花數(shù)。
一位自冪數(shù):獨(dú)身數(shù)
兩位自冪數(shù):沒有
三位自冪數(shù):水仙花數(shù)
四位自冪數(shù):四葉玫瑰數(shù)
五位自冪數(shù):五角星數(shù)
六位自冪數(shù):六合數(shù)
七位自冪數(shù):北斗七星數(shù)
八位自冪數(shù):八仙數(shù)
九位自冪數(shù):九九重陽數(shù)
十位自冪數(shù):十全十美數(shù)
參考資料:
水仙花數(shù)——百度百科
網(wǎng)頁名稱:java代碼編寫水仙花,java水仙花三種方法
本文路徑:http://chinadenli.net/article9/dsecioh.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、動態(tài)網(wǎng)站、面包屑導(dǎo)航、標(biāo)簽優(yōu)化、做網(wǎng)站、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)