题解 | #水仙花数#

水仙花数

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

#include <stdio.h>
#include <math.h>
int main() {
    int n,m,a=0,b=0,c=0;
    while(scanf("%d %d",&n,&m)!=EOF){
        for(n;n<=m;n++){
            b=n;
            for(;b>0;b/=10){
                a=a+pow((b%10),3);
            }
            if(a==n){
                printf("%d ",n);
                c++;
            }
            a=0;
        }
        if(0==c) printf("no\n");
        c=0;
    }
    return 0;
}

全部评论

相关推荐

点赞 评论 收藏
分享
皮格吉:不,有的厂子面试无手撕,可以试试。都是一边学一边面。哪有真正准备好的时候,别放弃
无实习如何秋招上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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