[Problem]
将十进制数n转换成m进制数 m<=16, n<=100
[Solution]
#include <vector> #include <iostream> using namespace std;char table[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};int main(){int n, m;while(cin >> n >> m){vector<char> result;while(n >= m){result.insert(result.begin(), table[n%m]);n /= m;}if(n > 0 || (n == 0 && result.size() == 0)){result.insert(result.begin(), table[n]);}// output resultfor(int i = 0; i < result.size(); ++i){cout << result[i];}cout << endl;}return 0; }