2.1-20000内的水花仙数字

#include <iostream>
#include <math.h>
using namespace std;


int main()
{
    int num = 0,count=0,sum = 0;
    cin >> num;
    int x = num;
    while(x!=0){
        x=x/10;
        count++;
    }
    x= num;
    for(int i = 0;i<count;i++){
        sum += pow((x%10),count);
        x = x/10;
    }
    if(sum==num){
        cout << "这个数字是水仙花数" << endl;
    }else{
            cout << "这个数字不是水仙花数" << endl;
    }
    return 0;
}

posted @ 2023-08-23 19:40  TCcjx  阅读(6)  评论(0编辑  收藏  举报