题目:
题解:
char * toHex(int num){int i=0;char *nums=(char*)malloc(sizeof(char)*32);unsigned int newnum=(unsigned int)num;if(num==0){nums[0]='0';nums[1]='\0';return nums;}while(newnum>=1){int flag=newnum%16;newnum/=16;if(flag<=9){nums[i]=flag+'0';i++;}else{nums[i]='a'+flag-10;i++;}}int left=0,right=i-1;nums[i]='\0';while(left<right){char ch=nums[left];nums[left]=nums[right];nums[right]=ch;left++;right--;}return nums;
}