From 7e7124efd5e06877699537b42a1f35d4e2e2d6cb Mon Sep 17 00:00:00 2001 From: Nicholay Shestakov Date: Tue, 30 Sep 2025 08:46:21 +0300 Subject: [PATCH 01/12] Add simple bracket balance homework --- .../simple_bracket_balance.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/compilation_process/simple_bracket_balance/simple_bracket_balance.c diff --git a/src/compilation_process/simple_bracket_balance/simple_bracket_balance.c b/src/compilation_process/simple_bracket_balance/simple_bracket_balance.c new file mode 100644 index 0000000..ca07042 --- /dev/null +++ b/src/compilation_process/simple_bracket_balance/simple_bracket_balance.c @@ -0,0 +1,29 @@ +#include + +int main() +{ + char character = 0; + int countNotClosedBrackets = 0; + + printf("Enter string: "); + do { + scanf("%c", &character); + + if (character == '(') { + countNotClosedBrackets++; + } + if (character == ')') { + countNotClosedBrackets--; + } + + if (countNotClosedBrackets < 0) { + break; + } + } while (character != '\n'); + + if (countNotClosedBrackets == 0) { + printf("Brackets balanced. \n"); + } else { + printf("Brackets not balanced. \n"); + } +} From 393cea9b97cee35a36def445707ea4005c41fc05 Mon Sep 17 00:00:00 2001 From: Nicholay Shestakov Date: Tue, 30 Sep 2025 17:23:04 +0300 Subject: [PATCH 02/12] Add search for a substring homework --- .../search_for_a_substring.c | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/compilation_process/search_for_a_substring/search_for_a_substring.c diff --git a/src/compilation_process/search_for_a_substring/search_for_a_substring.c b/src/compilation_process/search_for_a_substring/search_for_a_substring.c new file mode 100644 index 0000000..7deed9c --- /dev/null +++ b/src/compilation_process/search_for_a_substring/search_for_a_substring.c @@ -0,0 +1,35 @@ +#include +#include + +int main() +{ + char* string = NULL; + char* substring = NULL; + size_t stringSize = 0; + size_t substringSize = 0; + + printf("Enter string: "); + int realStringSize = getline(&string, &stringSize, stdin); + printf("Enter substring: "); + int realSubstringSize = getline(&substring, &substringSize, stdin); + + int substringCount = 0; + for (int i = 0; i < realStringSize - 1; i++) { + if (string[i] == substring[0]) { + substringCount++; + for (int j = 0; j < realSubstringSize - 1; j++) { + if (string[i + j] != substring[j]) { + substringCount--; + break; + } + } + } + } + + printf("Substring count in string: %d \n", substringCount); + + free(string); + free(substring); + + return 0; +} From c9fa92e6674f93244f2268e0073aceab4f92e2b5 Mon Sep 17 00:00:00 2001 From: Nicholay Shestakov Date: Thu, 11 Dec 2025 14:05:03 +0300 Subject: [PATCH 03/12] Add hello world --- src/hello_world/hello_world.c | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/hello_world/hello_world.c diff --git a/src/hello_world/hello_world.c b/src/hello_world/hello_world.c new file mode 100644 index 0000000..88682ec --- /dev/null +++ b/src/hello_world/hello_world.c @@ -0,0 +1,8 @@ +#include + +int main() +{ + printf("Hello, World!\n"); + + return 0; +} From acf84a29a96d8f69c27858ed88b70d509b7b1669 Mon Sep 17 00:00:00 2001 From: Nicholay Shestakov Date: Thu, 11 Dec 2025 14:05:34 +0300 Subject: [PATCH 04/12] Add CMakeLists for hello world build --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..37cb1cd --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.25) + +# Hello World +project(hello_world C) + +add_executable(hello_world src/hello_world/hello_world.c) +target_compile_options(hello_world PRIVATE -Wall -Wextra -pedantic) From 2283baaad27cd11ad54fbbc58dc9643897f83259 Mon Sep 17 00:00:00 2001 From: Nicholay Shestakov Date: Thu, 11 Dec 2025 14:06:01 +0300 Subject: [PATCH 05/12] Add build folder in gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index b48d248..af47ed6 100644 --- a/.gitignore +++ b/.gitignore @@ -55,4 +55,7 @@ Module.symvers Mkfile.old dkms.conf +#CMake +build + # End of https://www.toptal.com/developers/gitignore/api/c From 8b35d38716cbf2385bb6b380d61d36b54d5d4b32 Mon Sep 17 00:00:00 2001 From: Nicholay Shestakov Date: Thu, 11 Dec 2025 14:06:21 +0300 Subject: [PATCH 06/12] Add build instruction for hello world --- src/hello_world/build_instruction.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/hello_world/build_instruction.md diff --git a/src/hello_world/build_instruction.md b/src/hello_world/build_instruction.md new file mode 100644 index 0000000..80089c4 --- /dev/null +++ b/src/hello_world/build_instruction.md @@ -0,0 +1,5 @@ +# Build instruction +```console +$ cmake . -B build +$ cmake --build build +``` From fed30ea17a79859ca46217a4752ec9b09ce95079 Mon Sep 17 00:00:00 2001 From: Nicholay Shestakov Date: Thu, 11 Dec 2025 14:12:50 +0300 Subject: [PATCH 07/12] Delete build instruction --- src/hello_world/build_instruction.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 src/hello_world/build_instruction.md diff --git a/src/hello_world/build_instruction.md b/src/hello_world/build_instruction.md deleted file mode 100644 index 80089c4..0000000 --- a/src/hello_world/build_instruction.md +++ /dev/null @@ -1,5 +0,0 @@ -# Build instruction -```console -$ cmake . -B build -$ cmake --build build -``` From 07cdc76c6a2b9a102cfb4ca7bd284be53bda7466 Mon Sep 17 00:00:00 2001 From: Nicholay Shestakov Date: Thu, 11 Dec 2025 14:13:22 +0300 Subject: [PATCH 08/12] Add build instruction in README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 8d586e5..ab05d77 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,9 @@ Основная почта: nicholas.shestakov@gmail.com Телеграм: @Kolya_shesterka + +## Инструкции по сборке: +```console +$ cmake . -B build +$ cmake --build build +``` From bd5f8ffd79bdfa8a040d41b0135bbdb4175e429f Mon Sep 17 00:00:00 2001 From: Nicholay Shestakov Date: Thu, 11 Dec 2025 14:22:18 +0300 Subject: [PATCH 09/12] Add CMakeLists for hw 2 build --- CMakeLists.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37cb1cd..0170f6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,3 +5,27 @@ project(hello_world C) add_executable(hello_world src/hello_world/hello_world.c) target_compile_options(hello_world PRIVATE -Wall -Wextra -pedantic) + +# Fast calculation of polynomial +project(fast_calc_of_polynom C) + +add_executable(fast_calc_of_polynom src/homework_deadline_25_sep/fast_calculation_of_polynomial/fast_calculation_of_polynomial.c) +target_compile_options(fast_calc_of_polynom PRIVATE -Wall -Wextra -pedantic) + +# Incomplete quotient +project(incomplete_quotient C) + +add_executable(incomplete_quotient src/homework_deadline_25_sep/incomplete_quotient/incomplete_quotient.c) +target_compile_options(incomplete_quotient PRIVATE -Wall -Wextra -pedantic) + +# Lucky tickets +project(lucky_tickets C) + +add_executable(lucky_tickets src/homework_deadline_25_sep/lucky_tickets/lucky_tickets.c) +target_compile_options(lucky_tickets PRIVATE -Wall -Wextra -pedantic) + +# Massive reroll +project(massive_reroll C) + +add_executable(massive_reroll src/homework_deadline_25_sep/massive_reroll/massive_reroll.c) +target_compile_options(massive_reroll PRIVATE -Wall -Wextra -pedantic) From 3f48d549957b1f8ebb10cf8f9988c7f0c884f894 Mon Sep 17 00:00:00 2001 From: Nicholay Shestakov Date: Thu, 18 Dec 2025 16:20:11 +0300 Subject: [PATCH 10/12] Update CMakeLists --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37cb1cd..6e24d33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.25) +project(C_homework C) +add_compile_options(-Wall -Wextra -pedantic) -# Hello World -project(hello_world C) +# Libraries +# Executables and links with libraries add_executable(hello_world src/hello_world/hello_world.c) -target_compile_options(hello_world PRIVATE -Wall -Wextra -pedantic) From d88c955ae90d79b27da0830e91e46b5f4a92d1dd Mon Sep 17 00:00:00 2001 From: Nicholay Shestakov Date: Thu, 18 Dec 2025 16:20:11 +0300 Subject: [PATCH 11/12] Update CMakeLists --- CMakeLists.txt | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0170f6c..64688db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,31 +1,16 @@ cmake_minimum_required(VERSION 3.25) +project(C_homework C) +add_compile_options(-Wall -Wextra -pedantic) -# Hello World -project(hello_world C) +# Libraries +# Executables and links with libraries add_executable(hello_world src/hello_world/hello_world.c) -target_compile_options(hello_world PRIVATE -Wall -Wextra -pedantic) - -# Fast calculation of polynomial -project(fast_calc_of_polynom C) add_executable(fast_calc_of_polynom src/homework_deadline_25_sep/fast_calculation_of_polynomial/fast_calculation_of_polynomial.c) -target_compile_options(fast_calc_of_polynom PRIVATE -Wall -Wextra -pedantic) - -# Incomplete quotient -project(incomplete_quotient C) add_executable(incomplete_quotient src/homework_deadline_25_sep/incomplete_quotient/incomplete_quotient.c) -target_compile_options(incomplete_quotient PRIVATE -Wall -Wextra -pedantic) - -# Lucky tickets -project(lucky_tickets C) add_executable(lucky_tickets src/homework_deadline_25_sep/lucky_tickets/lucky_tickets.c) -target_compile_options(lucky_tickets PRIVATE -Wall -Wextra -pedantic) - -# Massive reroll -project(massive_reroll C) add_executable(massive_reroll src/homework_deadline_25_sep/massive_reroll/massive_reroll.c) -target_compile_options(massive_reroll PRIVATE -Wall -Wextra -pedantic) From 87068e0f87148f4406d3d5f696a8e8b70946188a Mon Sep 17 00:00:00 2001 From: Nicholay Shestakov Date: Thu, 18 Dec 2025 17:08:22 +0300 Subject: [PATCH 12/12] Add CMake for homework number 3 --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 988b579..ffd031b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,3 +18,9 @@ add_executable(massive_reroll src/homework_deadline_25_sep/massive_reroll/massiv add_executable(sorting_station src/stack_and_queue/stack/sorting_station.c) target_link_libraries(sorting_station PRIVATE stack) + +add_executable(number_of_zero_elements src/compilation_process/number_of_zero_elements/number_of_zero_elements.c) + +add_executable(simple_bracket_balance src/compilation_process/simple_bracket_balance/simple_bracket_balance.c) + +add_executable(search_for_a_substring src/compilation_process/search_for_a_substring/search_for_a_substring.c)