求水仙花数
- #include <iostream>
- using namespace std;
-
- int main()
- {
- int n = 100;
-
- do {
- int a = 0;
- int b = 0;
- int c = 0;
-
- a = n % 10; //个位
- b = n / 10 % 10; //十位
- c = n / 100 % 10; //百位
-
- if (a * a * a + b * b * b + c * c * c == n) {
- cout << n << endl;
- }
-
- n++;
- }
- while (n < 1000);
-
- system("pause");
-
- return 0;
- }