题解 | #水仙花数#

水仙花数

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

#include<stdio.h>
int main() {
    int m, n;

    int a, b, c;
    while (scanf("%d %d", &m, &n) != EOF) {
        int flag = 0;
        for (int i = m; i <= n; i++) {

            a = i / 100; //个位哦
            b = (i % 100) / 10; //十位嗷
            c = i % 10;  //百位
            if (a * a * a + b * b * b + c * c * c == i) {
                flag++;
                printf("%d ", i);
            }
        }
        if (flag == 0)
            printf("no\n");

        else
            printf("\n");
    }

}
C语言刷题 文章被收录于专栏

自己从头开始刷的C语言

全部评论
个十百位写反了
1 回复 分享
发布于 2024-03-16 20:28 内蒙古

相关推荐

牛客96931767...:这履历不是在网安横着走啊
大家都开始春招面试了吗
点赞 评论 收藏
分享
评论
7
收藏
分享

创作者周榜

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