Calculate the number of daffodils

xiaoxiao2021-03-06  107

/ * There is a topic is to output all the number of daffodils, and the number of daffodils refers to a 3-digit, and its numbers are cubic and equal to the number itself. For example: 153 = 1 3 square 5 of the 3 times 3 squares. * / # include #include

Using namespace std;

#define trimp (x) * (x) * (x)

INT main () {cout << "The number of daffodils is:" << endl;

INT B, C, D, TMP; B = C = D = 0; for (int N = 100; n <= 999; N) {b = trimesp (n / 100); c = trimp ((n% 100) / 10); D = trimp ((N% 100)% 10); TMP = B C D; if (n == TMP) cout << n << endl;}

Getch (); return 0;}

转载请注明原文地址:https://www.9cbs.com/read-101272.html

New Post(0)