KleptsovKD 3 месяцев назад
Сommit e68529c8b0

4
lab04/.gitignore поставляемый

@ -0,0 +1,4 @@
/bin
/obj
/lab04.depend
/lab04.layout

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="lab04" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/lab04" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/lab04" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename=".gitignore" />
<Unit filename="main.cpp" />
<Extensions>
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>

@ -0,0 +1,47 @@
#include <iostream>
#include <cassert>
using namespace std;
char nibble_to_hex(uint8_t i) //Conversion to hex format
{
assert(0x0 <= i && i <= 0xf);
//return "0123456789abcdef"[i];
if (i < 10)
{
return i + '0';
}
else
{
return 'a' + (i - 10);
}
}
int main()
{
assert(nibble_to_hex(0x0) == '0');
assert(nibble_to_hex(0x1) == '1');
assert(nibble_to_hex(0x2) == '2');
assert(nibble_to_hex(0x3) == '3');
assert(nibble_to_hex(0x4) == '4');
assert(nibble_to_hex(0x5) == '5');
assert(nibble_to_hex(0x6) == '6');
assert(nibble_to_hex(0x7) == '7');
assert(nibble_to_hex(0x8) == '8');
assert(nibble_to_hex(0x9) == '9');
assert(nibble_to_hex(0xa) == 'a');
assert(nibble_to_hex(0xb) == 'b');
assert(nibble_to_hex(0xc) == 'c');
assert(nibble_to_hex(0xd) == 'd');
assert(nibble_to_hex(0xe) == 'e');
assert(nibble_to_hex(0xf) == 'f');
cout << "Press any key for exit... ";
cin.get();
return 0;
}
Загрузка…
Отмена
Сохранить