n转m进制标准写法(必须记忆)

#include <bits/stdc++.h>
using namespace std;





int main()
{
    int n,m;
    cin >> n >> m;
    char s[17] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
    string str = "";
    int i;
    while(n)
    {
        i = n%m;
        n = n/m;
        str = s[i] + str;
    }
    cout << str;


    return 0;
}

第一:奇葩的万能头文件

第二:char中只能用单引号

第三:itoa不是在所有编译器中都能用

原文地址:https://www.cnblogs.com/cunyusup/p/7733055.html