diff --git a/works/C(system program)/1.1.c b/works/C(system program)/1.1.c new file mode 100644 index 0000000..d325fe0 --- /dev/null +++ b/works/C(system program)/1.1.c @@ -0,0 +1,13 @@ +/* Type your code here, or load an example. */ +#include +#include +#include +#include +int main(void) { +int a = 26; +int b = 5; +int c = a / b; +return 0; +} + + \ No newline at end of file diff --git a/works/C(system program)/1.1.png b/works/C(system program)/1.1.png new file mode 100644 index 0000000..0c38c41 Binary files /dev/null and b/works/C(system program)/1.1.png differ diff --git a/works/C(system program)/1.2.c b/works/C(system program)/1.2.c new file mode 100644 index 0000000..d5f4c4c --- /dev/null +++ b/works/C(system program)/1.2.c @@ -0,0 +1,17 @@ +/* Type your code here, or load an example. */ +#include +#include +#include +#include +// int main(void) { +// int a = 26; +// int b = 5; +// int c = a / b; +// return 0; +// } +unsigned short swap_bytes(unsigned short num) { + return ((num & 0x00FF) << 8) | ((num >> 8)); + } + + + \ No newline at end of file diff --git a/works/C(system program)/1.2.png b/works/C(system program)/1.2.png new file mode 100644 index 0000000..ed34861 Binary files /dev/null and b/works/C(system program)/1.2.png differ diff --git a/works/C(system program)/1.3.png b/works/C(system program)/1.3.png new file mode 100644 index 0000000..008722f Binary files /dev/null and b/works/C(system program)/1.3.png differ diff --git a/works/C(system program)/1.4.png b/works/C(system program)/1.4.png new file mode 100644 index 0000000..52c6484 Binary files /dev/null and b/works/C(system program)/1.4.png differ diff --git a/works/C(system program)/1.5.c b/works/C(system program)/1.5.c new file mode 100644 index 0000000..9a05701 --- /dev/null +++ b/works/C(system program)/1.5.c @@ -0,0 +1,13 @@ +#include + +int main(void) { + const long long x = 5; + long long factorial = 1; + + for (long long i = 1; i <= x; ++i) { + factorial *= i; + } + + printf("%lld! = %lld\n", x, factorial); + return 0; +} \ No newline at end of file diff --git a/works/C(system program)/readme.md b/works/C(system program)/readme.md new file mode 100644 index 0000000..041c1ed --- /dev/null +++ b/works/C(system program)/readme.md @@ -0,0 +1,19 @@ +## Юсуфов Алим +### Ex 1 +![solution ex1](1.1.png) + +### Ex 2 +![solution ex2](1.2.png) + +### Ex 3 +![solution ex3](1.3.png) + +### Ex 4 +![solution ex4](1.4.png) + +## Ex 5 +## Описание уровней оптимизации + **-O0** — цикл остаётся циклом: генерируются инструкции сравнения, перехода и умножения в точном соответствии с исходным кодом. +- **-O1** — базовые оптимизации: структура цикла сохраняется, удаляются лишние операции. +- **-O2** — полное развёртывание цикла (loop unrolling): вместо цикла — последовательность умножений; инструкции сравнения и переходов отсутствуют. +- **-O3** — дополнительно применяется сворачивание констант (constant folding): при известных входных данных компилятор подставляет готовый результат (например, для `x = 5` — значение `120`). \ No newline at end of file