题解 | #水仙花数#

水仙花数

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

#include <stdio.h>
#include<math.h>

int main() 
{
    int a, b;
    int tmp = 1;
    while(scanf("%d %d\n",&a, &b)!=EOF)
    {
        int i = 0;
        for(i = a; i<= b; i++)
        {
            if(i == pow(i%10,3)+pow(i/10%10,3)+pow(i/100,3))
            {
                tmp = 0;
                printf("%d ",i); 
            }   
        }
        if(tmp == 1)
            printf("no");
        printf("\n");
    }
}

全部评论

相关推荐

04-25 19:29
已编辑
宁波大学 运营
被普调的六边形战士很高大:你我美牛孩
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务