1015水仙花

 1 // Test015-1015水仙花.cpp: 定义控制台应用程序的入口点。
 2 //
 3 
 4 #include "stdafx.h"
 5 
 6 int triple(int a)
 7 {
 8     return a*a*a;
 9 }
10 bool flowerNum(int num)
11 {
12     int flat[4] = { 0 };
13     int temp = num;
14     for (int i = 0; i < 3; i++)
15     {
16         flat[i] = num % 10;
17         num /= 10;
18     }
19     if (temp == triple(flat[0]) + triple(flat[1]) + triple(flat[2]))
20         return true;
21     else
22         return false;
23     
24 }
25 
26 
27 int main()
28 {
29     for(int i=100;i<1000;i++)
30     {
31         if (flowerNum(i))
32             printf("%d\n", i);
33     
34     }
35     //flowerNum(153);
36     return 0;
37 }

 

posted @ 2018-07-18 17:16  kongchung  阅读(103)  评论(0编辑  收藏  举报