I have to convert hexadecimal numbers to octal numbers by converting hex numbers to binary first, and from binary to octal.
#include <stdio.h>
#include <string.h>
int main(){
char binarni_brojevi[16][5] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
char heksadekadni_broj[] = "AF1";
int i, vrednost;
char binarni[50];
binarni[0] = '';
for(i = 0; heksadekadni_broj[i]; i++) {
if(isalpha(heksadekadni_broj[i]))
vrednost = (heksadekadni_broj[i] - 'A' + 10);
else
vrednost = (heksadekadni_broj[i] - '0');
strcat(binarni, binarni_brojevi[vrednost]);
}
// what do I do from here? How should I group by 3
return 0;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…