手记

c++水线花数(未优化)

#include <iostream>
using namespace std;
int main()
{
    for (int i = 111; i <= 999; ++i) {
        int a = i / 100;
        a = a*a*a;
        int b = i %100/10;
        b = b*b*b;
        int c = i % 10;
        c = c*c*c;
        if (a!=b&&a!=c&&b!=c&&a+b+c == i) {
            cout << i << endl;
        }
    }
    return 0;
}
9人推荐
随时随地看视频
慕课网APP