进制转换
#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; }
posted on 2021-01-12 14:09 wlqsmiling 阅读(57) 评论(0) 编辑 收藏 举报