全部评论 2

  • #include <iostream>
    #include <string>
    using namespace std;
    
    string convert_to_base(int a, int b) {
        if (a == 0) {
            return "";
        }
        int c = a % b;
        char c_char;
        if (c < 10) {
            c_char = '0' + c;
        } else {
            c_char = 'A' + c - 10;
        }
        return convert_to_base(a / b, b) + c_char;
    }
    
    int main() {
        int a, b;
        cin >> a >> b;
        if (a == 0) {
            cout << 0 << endl;
        } else {
            cout << convert_to_base(a, b) << endl;
        }
        return 0;
    }
    
    

    昨天 来自 浙江

    0
  • #include <iostream>
    #include <string>
    using namespace std;

    string convert_to_base(int a, int b) {
    if (a == 0) {
    return "";
    }
    int c = a % b;
    char c_char;
    if (c < 10) {
    c_char = '0' + c;
    } else {
    c_char = 'A' + c - 10;
    }
    return convert_to_base(a / b, b) + c_char;
    }

    int main() {
    int a, b;
    cin >> a >> b;
    if (a == 0) {
    cout << 0 << endl;
    } else {
    cout << convert_to_base(a, b) << endl;
    }
    return 0;
    }

    昨天 来自 浙江

    0
暂无数据

提交答案之后,这里将显示提交结果~

首页