Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
32bea4f
Create Демидова_Софья_4091.txt
S0NIC-the-hedgehog Sep 9, 2025
45e110d
LAB1 (update 1)
S0NIC-the-hedgehog Sep 30, 2025
4862cc0
LAB1 (update 2)
S0NIC-the-hedgehog Oct 1, 2025
8abe39b
LAB1 (update 3)
S0NIC-the-hedgehog Oct 2, 2025
4f7d75f
LAB1 (update 4)
S0NIC-the-hedgehog Oct 3, 2025
d75a228
LAB1 (update 4.1)
S0NIC-the-hedgehog Oct 3, 2025
a9271e3
LAB1 (update 5)
S0NIC-the-hedgehog Oct 6, 2025
d37216d
LAB2 (update 0)
S0NIC-the-hedgehog Oct 10, 2025
004b957
LAB2 (update 1)
S0NIC-the-hedgehog Oct 16, 2025
31b1bdd
LAB2 (update 1.2)
S0NIC-the-hedgehog Oct 17, 2025
84533b7
LAB2 (update 2)
S0NIC-the-hedgehog Oct 19, 2025
31739b6
LAB2 (update 3)
S0NIC-the-hedgehog Oct 21, 2025
d0128e3
LAB2 (update 4)
S0NIC-the-hedgehog Oct 22, 2025
afb33cb
LAB2 (update 5)
S0NIC-the-hedgehog Oct 23, 2025
eb15b97
LAB2 (update 6)
S0NIC-the-hedgehog Oct 24, 2025
fd99589
LAB2 (update 7)
S0NIC-the-hedgehog Oct 28, 2025
9271cfc
LAB2 (update 8)
S0NIC-the-hedgehog Oct 29, 2025
22d9254
LAB3 (update 1)
S0NIC-the-hedgehog Nov 12, 2025
6fc1b47
LAB3 (update 2)
S0NIC-the-hedgehog Nov 13, 2025
a6750e9
LAB3 (update 3)
S0NIC-the-hedgehog Nov 16, 2025
eab4850
LAB2 (p.s 1)
S0NIC-the-hedgehog Nov 17, 2025
0e56ac4
LAB3 (update 4)
S0NIC-the-hedgehog Nov 17, 2025
9a19a6b
Merge branch 'master' of https://github.com/S0NIC-the-hedgehog/Algori…
S0NIC-the-hedgehog Nov 17, 2025
461d516
LAB4 (update 0)
S0NIC-the-hedgehog Nov 25, 2025
bb9a72c
LAB4 (update 0.1)
S0NIC-the-hedgehog Nov 26, 2025
c489bd6
LAB4 (update 1)
S0NIC-the-hedgehog Nov 27, 2025
7ff22aa
LAB4 (update 2)
S0NIC-the-hedgehog Dec 1, 2025
2b4c9ce
LAB4 (update 3)
S0NIC-the-hedgehog Dec 2, 2025
5abc043
LAB4 (update 4)
S0NIC-the-hedgehog Dec 3, 2025
5c18cf3
LAB4 (update 5)
S0NIC-the-hedgehog Dec 4, 2025
7e88c16
LAB4 (update 6)
S0NIC-the-hedgehog Dec 5, 2025
1ade65a
LAB4 (update 7)
S0NIC-the-hedgehog Dec 11, 2025
c5fd952
LAB4 (update 8)
S0NIC-the-hedgehog Dec 12, 2025
d10ef44
LAB4 (update 9)
S0NIC-the-hedgehog Dec 15, 2025
30d1691
LAB4 (update 10)
S0NIC-the-hedgehog Dec 18, 2025
f80505c
LAB4 (update 11)
S0NIC-the-hedgehog Dec 19, 2025
7c7d13b
действительная удобная ссылка на статью ИТМО о алгоритме A*
S0NIC-the-hedgehog Jan 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ else()
add_compile_options(-Wall -Wextra -Wpedantic -Wno-gnu-empty-struct -Wno-unused-parameter)
endif()

add_subdirectory(LibraryC)
add_subdirectory(LibraryCPP)
add_subdirectory(LibraryCPPClass)
#add_subdirectory(LibraryC)
#add_subdirectory(LibraryCPP)
#add_subdirectory(LibraryCPPClass)
add_subdirectory(LibraryCPPTemplate)

add_subdirectory(Lab1C)
#add_subdirectory(Lab1C)
#add_subdirectory(Lab1CPP)
#add_subdirectory(Lab2CPP)
#add_subdirectory(Lab3CPP)
add_subdirectory(Lab4CPPTemplate)
4 changes: 2 additions & 2 deletions Lab1C/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ add_executable(Lab1C lab1.c)
target_include_directories(Lab1C PUBLIC ../LibraryC)
target_link_libraries(Lab1C LibraryC)

add_test(NAME TestLab1C COMMAND Lab1C ${CMAKE_CURRENT_SOURCE_DIR}/input.txt)
set_property(TEST TestLab1C PROPERTY PASS_REGULAR_EXPRESSION "1 2 3 4 5")
#add_test(NAME TestLab1C COMMAND Lab1C ${CMAKE_CURRENT_SOURCE_DIR}/input.txt)
#set_property(TEST TestLab1C PROPERTY PASS_REGULAR_EXPRESSION "1 2 3 4 5")
8 changes: 8 additions & 0 deletions Lab1CPP/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
add_executable(Lab1CPP lab1.cpp)
target_include_directories(Lab1CPP PUBLIC ../LibraryCPP)
target_link_libraries(Lab1CPP LibraryCPP)

add_test(NAME TestLab1CPP COMMAND $<TARGET_FILE:Lab1CPP> ${CMAKE_CURRENT_SOURCE_DIR}/input.txt)
set_property(TEST TestLab1CPP PROPERTY PASS_REGULAR_EXPRESSION "2 3 5 7 11.*5 6 7 8 9")


4 changes: 4 additions & 0 deletions Lab1CPP/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
10
10
1 2 3 4 5 6 7 8 9 0

122 changes: 122 additions & 0 deletions Lab1CPP/lab1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#include <iostream>
#include <fstream>
#include "array.h"

Array *array_create_and_read(std::istream& input)
{
size_t n;
input >> n;

/* Create array */
Array *arr = array_create(n);
/* Read array data */
for (size_t i = 0 ; i < n ; ++i)
{
Data x;
input >> x;
array_set(arr, i, x);
}
return arr;
}

Array* array_create_read_size(std::istream& input)
{
size_t n;
input >> n;
return array_create(n);
}


bool is_prime(int n)
{
if (n < 2) return false;
for (int i = 2; i * i <= n; ++i)
if (n % i == 0)
return false;
return true;
}

/*Read an integer from a file, create an array of this size.
Fill the array with prime numbers, starting with 2. Display the array on the screen.*/
void task1(Array *arr)
{
array_set(arr, 0, 2);
int num = 3;
for (size_t i = 1; i < array_size(arr); ++num)
{
if (is_prime(num))
{
array_set(arr, i, num);
++i;
}

}


for (size_t i = 0; i < array_size(arr); ++i)
{
std::cout << array_get(arr, i) << " ";
}
std::cout << "\n";

}

/*Read an integer from a file, create an array of this size and
fill it with numbers from the file. Find five neighboring elements,
the sum of whose values is maximum. Display the result on the screen.*/
void task2(Array *arr)
{
size_t n = array_size(arr);
if (n < 5)
{
return;
}

int maxSum = 0;
int currSum = 0;
size_t indx = 0;

for (size_t i = 0; i < 5; ++i)
currSum += array_get(arr, i);
maxSum = currSum;

for (size_t i = 5; i < n; ++i)
{
currSum = currSum - array_get(arr, i - 5) + array_get(arr, i);
if (currSum > maxSum)
{
maxSum = currSum;
indx = i - 4;
}
}

for (size_t i = indx; i < indx + 5; ++i)
{
std::cout << array_get(arr, i) << " ";
}
std::cout << "\n";
}

int main(int argc, char **argv)
{
if (argc < 2)
{
return 1;
}

std::ifstream input(argv[1]);
if (!input)
{
return 1;
}

Array* arr = array_create_read_size(input);
task1(arr);
array_delete(arr);

arr = array_create_and_read(input);
task2(arr);
array_delete(arr);

return 0;
}
18 changes: 18 additions & 0 deletions Lab2CPP/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
add_executable(Lab2CPP lab2.cpp)
target_include_directories(Lab2CPP PUBLIC ../LibraryCPP)
target_link_libraries(Lab2CPP LibraryCPP)

add_test(NAME TestLab2CPP COMMAND $<TARGET_FILE:Lab2CPP> ${CMAKE_CURRENT_SOURCE_DIR}/input.txt ${CMAKE_CURRENT_SOURCE_DIR}/inputnum.txt)
set_property(TEST TestLab2CPP PROPERTY PASS_REGULAR_EXPRESSION "72 101 108")

add_test(NAME TestLab2CPP2 COMMAND $<TARGET_FILE:Lab2CPP> ${CMAKE_CURRENT_SOURCE_DIR}/input2.txt ${CMAKE_CURRENT_SOURCE_DIR}/inputnum.txt)
set_property(TEST TestLab2CPP2 PROPERTY PASS_REGULAR_EXPRESSION "5 10")

add_test(NAME TestLab2CPP3 COMMAND $<TARGET_FILE:Lab2CPP> ${CMAKE_CURRENT_SOURCE_DIR}/input3.txt ${CMAKE_CURRENT_SOURCE_DIR}/inputnum.txt)
set_property(TEST TestLab2CPP3 PROPERTY PASS_REGULAR_EXPRESSION "0")

add_test(NAME TestLab2CPP4 COMMAND $<TARGET_FILE:Lab2CPP> ${CMAKE_CURRENT_SOURCE_DIR}/input4.txt ${CMAKE_CURRENT_SOURCE_DIR}/inputnum.txt)
set_property(TEST TestLab2CPP4 PROPERTY PASS_REGULAR_EXPRESSION "10")

add_test(NAME TestLab2CPP5 COMMAND $<TARGET_FILE:Lab2CPP> ${CMAKE_CURRENT_SOURCE_DIR}/input5.txt ${CMAKE_CURRENT_SOURCE_DIR}/inputnum.txt)
set_property(TEST TestLab2CPP5 PROPERTY PASS_REGULAR_EXPRESSION "10 20")
2 changes: 2 additions & 0 deletions Lab2CPP/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
10 33 100 108 114 119 32 44 111 108 101 72 peek setr peek setr peek peek setr peek setr peek setr peek setr peek setr peek setr peek setr peek setr peek setr peek setr

3 changes: 3 additions & 0 deletions Lab2CPP/input2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2 3 add peek sub peek mul peek div peek sqrt peek sq peek get peek cond end setr repeat peek


2 changes: 2 additions & 0 deletions Lab2CPP/input3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0 0 div peek

1 change: 1 addition & 0 deletions Lab2CPP/input4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
get peek
1 change: 1 addition & 0 deletions Lab2CPP/input5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10 peek 20 peek
2 changes: 2 additions & 0 deletions Lab2CPP/inputnum.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
10

Loading