题解 | #又一版 A+B#

又一版 A+B

https://www.nowcoder.com/practice/9255c05d45b8406c9b588d7c57aa920b

#include<iostream>
#include<string>
#include<vector>
using namespace std;

//习题6.2 又一版A+B
int main()
{
    int m, a, b;
    long long res;
    while (cin >> m) {
        if (m == 0) {
            break;
        }
        cin >> a >> b;
        res = a + b;
        if (res == 0) {
            cout << 0 << endl;
            continue;
        }
        vector<int> nums;
        while (res != 0) {
            nums.push_back(res % m);
            res /= m;
        }
        for (int i = nums.size() - 1; i >= 0; i--) {
            cout << nums[i];
        }
        cout << endl;
    }

    return 0;
}

全部评论

相关推荐

06-23 11:28
门头沟学院 Java
牛客91966197...:也有可能是点拒绝的时候自动弹的话术
点赞 评论 收藏
分享
qq乃乃好喝到咩噗茶:院校后面加上211标签,放大加粗,招呼语也写上211
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 14:23
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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