“蓝桥杯”练习系统 - 基础练习 - 特殊的数字

 

思路:

水仙花数, 取到每一位求立方的和判断.

 1 #include <iostream>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     ios::sync_with_stdio(false);
 7     cin.tie(0);
 8 
 9     for (int i = 100; i < 1000; i++) {
10         int a = i % 10;
11         int b = i / 10 % 10;
12         int c = i / 100;
13         if (i == a * a * a + b * b * b + c * c * c)
14             cout << i << endl;
15     }
16 
17     return 0;
18 }

 

posted @ 2020-02-01 16:59  域Anton  阅读(125)  评论(0)    收藏  举报