void decto16 (int a, char c[]) { // a为要转换的十进制数 将结果存放在数组c中 ,以数组形式输出
int y;
int k = 0;
do {
y = a % 16;
a = a / 16;
for (int i = 0; i <= 9; i++) {
if (y == i) {
c[k++] = '0' + i;
}
}
for (int i = 10; i <= 15; i++) {
if (y == i) {
int j;
j = i - 10;
c[k++] = 'A' + j;
}
}
} while (a != 0);
for (int i = 0; i <= k - 1; i++) {
cout << c[k - 1 - i];
}
}