题解 | #输出水仙花数#

输出水仙花数

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

#include <iostream>
using namespace std;

int main() {

    // write your code here......
    int a, b, c;
    int i = 0;
    for (i = 100; i < 1000; i++) {
        a = i / 100;
        b = (i / 10) % 10;
        c = (i % 100) % 10;
        if (i == (a * a * a) + (b * b * b) + (c * c * c))
            cout << i << endl;
    }

    return 0;
}

全部评论

相关推荐

05-30 12:03
山西大学 C++
offer来了我跪着...:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
评论
4
1
分享

创作者周榜

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