用c語言求0 999水仙花數

2021-09-10 06:33:04 字數 733 閱讀 4332

題目描述:

求出0〜999之間的所有「水仙花數」並輸出。「水仙花數」是指乙個三位數,其各位數字的立方和確好等於該數本身,如;153=1+5+3?,則153是乙個「水仙花數」。

/*在數論中,水仙花數(narcissistic number)也稱為自戀數、自冪數、阿姆斯壯數或阿姆斯特朗數(armstrong number),是指一n位數,其各個數之n次方和等於該數。

例如153、370、371及407就是三位數的水仙花數,其各個數之立方和等於該數:

153 = 1^3 + 5^3 + 3^3。

370 = 3^3 + 7^3 + 0^3。

371 = 3^3 + 7^3 + 1^3。

407 = 4^3 + 0^3 + 7^3。

*/

#include

#include

intmain()

}printf

("\n");

printf

("水仙花個數:%d\n"

, count)

;system

("pause");

return0;

}

結果顯示

水仙花數:0

1153

370371

407水仙花個數:6

請按任意鍵繼續.

..

C語言 求0 999之間的水仙花數

水仙花數 是指乙個三位數,其各位數字的立方和確好等於該數本身,如 153 1 5 3?則153是乙個 水仙花數 水仙花數也稱為自戀數 自冪數 阿姆斯壯數或阿姆斯特朗數,是指一n位數,其各個數字之n次方和等於該數。既然是求0 999之間的水仙花數,那意思就是求0 999之間的所有1位數 2位數 3位數...

題目 求0 999之間的水仙花數

實現 define crt secure no warnings include include include define m 3 define n 999 intmain if i sum sum 0 sum 1 return0 執行結果 擴充題目 求一定範圍內的自冪數 define crt ...

C語言求水仙花數

第一種方法 如下 include include include int main system pause return 0 第二種方法 如下 include include include int main system pause return 0 第三種方法,是對3位數水仙花數的乙個擴充套件...