题解 | #变种水仙花#

变种水仙花

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

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

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-25 20:45
点赞 评论 收藏
分享
06-04 09:27
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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