题解 | #变种水仙花#

变种水仙花

https://www.nowcoder.com/practice/c178e3f5cc4641dfbc8b020ae79e2b71

#include <stdio.h>
#include <math.h>
int main()
{
    int i = 0;
    
   
    for (i=10000;i<100000; i++)
    {
        int sum = 0;
        int n = 4;
        while (n)
        {
            int k = i;
            int tmp = pow(10, n);
            sum += (k / tmp) * (k % tmp);
            n = n - 1;
        }
        if (sum == i)
        {
            printf("%d ", i);
        }

    }
    return 0;
}

全部评论

相关推荐

東大沒有派對:这是好事啊(峰哥脸
我的秋招日记
点赞 评论 收藏
分享
09-14 20:51
四川大学 Java
慢热的鲸鱼在学习:985加粗就行了,第二个项目来不及准备也没事,省的写了问你你还不会。你只需准备面试八股和项目场景,剩下的交给985。即使面不过也没事,面试经验是最重要的,你现在不缺时间
简历中的项目经历要怎么写
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务