Đây là code của mình, giải hoài không ra mong mọi người chỉ bảo
#include <iostream>
#include <cstring>
using namespace std;
main()
{
char a[] = "0123456789ABCDEF";
char b[] = "111101111";
int n = 8, i, j, temp = 0, h[20], m = 0;
cout << "strlen(b) = " << strlen(b) << endl;
for(i = strlen(b) - 1; i > 0; i = i - 4)
{
for(j = i - 3; j <= i; j++)
{
if(b[j] == '1')
{
temp = temp + n;
n = n / 2;
}
else
n = n / 2;
}
cout << a[temp] << endl;
}
}