题解 | 数字之和

数字之和

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

#include <iostream>
using namespace std;

int func(long long n) {
    int res = 0;
    while (n) {
        res += n % 10;
        n /= 10;
    }
    return res;
}

int main() {
    long long n;
    while (cin >> n) {
        cout << func(n) << " " << func(n * n) << endl;
    }
}

全部评论

相关推荐

03-05 14:55
已编辑
哈尔滨工程大学 Java
Jhin4ever:别去,杂活太多,今天让你部署一下模型,明天让你写一下LLM工作流,后天要你研究一下Agent,想微调模型都难
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务