十进制转十六
[cpp]#include <iostream>
#include <cstdio>
#define M 1000
using namespace std;
int k = 0;
char a[20] = {'0','1','2','3','4','5','6','7','8','9','A',
'B','C','D','E','F'};
int change(int num, char *p){
int m;
while(num){
m = num%16;
num = num/16;
p[k++] = a[m];
}
return 1;
}
int main()
{
int val;
char temp[M];
printf("please input a num:\n");
scanf("%d", &val);
change(val, temp);
for(int j = k-1; j >= 0; j--){
printf("%c",temp[j]);
}
printf("\n");
return 0;
}
补充:移动开发 , Android ,