Odpowiedź :
#include <iostream>
using namespace std;
int tab_bin[256];
int size_num = 0;
void DEC_convert_to_BIN(int dec)
{
int flag = 0;
if (dec == 0)
{
tab_bin[0] = 0;
flag++;
}
for (int i = 0; dec > 0; i++)
{
flag++;
if (dec % 2)
{
tab_bin[i] = 1;
dec /= 2;
}
else
{
tab_bin[i] = 0;
dec /= 2;
}
}
size_num = flag;
while (flag != 0)
{
cout << tab_bin[flag - 1];
flag--;
}
}
void BIN_convert_to_OKT()
{
int tab_okt[256];
int flag = 0;
int i = 0;
while (flag < size_num)
{
int suma = 0;
if (tab_bin[flag] == 1)
{
suma += 1;
}
if (tab_bin[flag + 1] == 1)
{
suma += 2;
}
if (tab_bin[flag + 2] == 1)
{
suma += 4;
}
tab_okt[i] = suma;
i++;
flag += 3;
}
while (i != 0)
{
cout << tab_okt[i - 1];
i--;
}
}
void BIN_convert_to_HEX()
{
string s = "0123456789ABCDEF";
string tab_hex[256];
int flag = 0;
int i = 0;
while (flag < size_num)
{
int suma = 0;
if (tab_bin[flag] == 1)
{
suma += 1;
}
if (tab_bin[flag + 1] == 1)
{
suma += 2;
}
if (tab_bin[flag + 2] == 1)
{
suma += 4;
}
if (tab_bin[flag + 3] == 1)
{
suma += 8;
}
tab_hex[i] = s[suma];
i++;
flag += 4;
}
while (i != 0)
{
cout << tab_hex[i - 1];
i--;
}
}
int main()
{
cout << "Wprowadz liczbe (DEC) : ";
int dec;
cin >> dec;
cout << "\n";
DEC_convert_to_BIN(dec);
cout << "\n";
BIN_convert_to_OKT();
cout << "\n";
BIN_convert_to_HEX();
return 0;
}