#include <iostream> #include <vector> #include <string> using namespace std; //进制转换 class Solution { public: string changeValue(int M, int N) { string str = ""; char *arr = {"0123456789ABCDEF"}; int mode = 0; while (M != 0) { str = arr[M % N] + str; M = M / N; } return str; } }; int main() { Solution sol; string str = sol.changeValue(8, 2); cout << str << endl; }