10进制转为16进制
#include <iostream>#include <string>using namespace std;char ToHexChar(int n){ return n<10 ? n+'0' : n-10+'A';}string foo(unsigned int n){ char t, buff[32]={'0','x', 0}; int i = 2, j = 2; do buff[i++] = ToHexChar(n%16); while (n/=16); for (--i; j < i; ++j, --i) t = buff[i], buff[i] = buff[j], buff[j] = t; return buff;}int main(){ unsigned int n; while (cin >> n) cout << foo(n) << endl; return 0;}