求一个100-999之间的水仙花数

水仙花数:num = 各个数的立方和

#include <iostream>

using namespace std;

int main() {

    int num = 100;
    do{
        int one = num % 10;
        int two = num /10 % 10;
        int three = num /100 ;
        if(one * one * one + two * two * two + three * three * three == num){
            cout<< num <<" ,是水仙花树"<< endl;
        }

        num ++;
    }while (num < 1000);


    return 0;
}

 

posted @ 2020-10-12 22:37  冬马党  阅读(383)  评论(0编辑  收藏  举报