C ++ implementation decimal turn hexadecimal
#include <stdio.h> #include <stdlib.h> #include < String > the using namespace STD; // arbitrary characters are converted to decimal, where az represents 10-35, AZ representatives 36-61, with the corresponding ASCII code adjust like char i2char ( int n-) { IF (n-> = 0 && n-<= . 9 ) return ' 0 ' + n-; IF (n-> = 10 && n-<= 35 ) return ' A ' + (N- 10 ); the else return ' A '+(n-36); } template<typename T> string num2str62(T& n) { char buf[1024]={0}; int index=0; while(n>0) { int m=n%62; n-=m; n/=62; buf[index++]=i2char(m); } string str=buf; string str2=string(str.rbegin(),str.rend()); return str2; } int main(int narg,char** args) { int n=10245; printf("%s\n",num2str62(n).c_str()); return 0; };