Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions 1476
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
121212
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ 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(LibraryCPPTemplate)

add_subdirectory(Lab1C)
add_subdirectory(Lab3CPPClass)
10 changes: 5 additions & 5 deletions Lab1C/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_executable(Lab1C lab1.c)
target_include_directories(Lab1C PUBLIC ../LibraryC)
target_link_libraries(Lab1C LibraryC)
# 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")
9 changes: 9 additions & 0 deletions Lab1CPPClass/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
add_executable(lab1cppclass struct1.cpp)
target_include_directories(lab1cppclass PUBLIC ../LibraryCPPClass)
target_link_libraries(lab1cppclass LibraryCPPClass)

add_test(NAME TestLab1CPPClass COMMAND lab1cppclass ${CMAKE_CURRENT_SOURCE_DIR}/input.txt)
set_property(TEST TestLab1CPPClass PROPERTY PASS_REGULAR_EXPRESSION "6 24 2 1 120.*7 2 6 1 0 0")

add_test(NAME TestLab1CPPClass1 COMMAND lab1cppclass ${CMAKE_CURRENT_SOURCE_DIR}/input1.txt)
set_property(TEST TestLab1CPPClass1 PROPERTY PASS_REGULAR_EXPRESSION "1 1 2 6.*10 3 8 2 1 0 0")
5 changes: 5 additions & 0 deletions Lab1CPPClass/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
5
3 4 2 1 5
6
3 7 2 4 6 1
3 5
5 changes: 5 additions & 0 deletions Lab1CPPClass/input1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
4
0 1 2 3
7
10 5 3 7 8 2 1
4 7
95 changes: 95 additions & 0 deletions Lab1CPPClass/struct1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#include <iostream>
#include <fstream>
#include <limits>
#include <cmath>
#include "array.h"

using namespace std;

long long factorial(int n) {
if (n < 0) return 0;
long long f = 1;
for (int i = 1; i <= n; i++)
f *= i;
return f;
}

void task4(Array& prarr) {
for (size_t i = 0; i < prarr.size(); i++) {
Data val = prarr.get(i);
prarr.set(i, factorial(val));
cout << prarr.get(i) << " ";
}
cout << endl;
}

void task5(Array& prarr, Data a, Data b) {
size_t write_index = 0;
size_t asize = prarr.size();

for (size_t i = 0; i < asize; i++) {
Data current = prarr.get(i);
if (current < a || current > b) {
prarr.set(write_index, current);
write_index++;
}
}

for (size_t i = write_index; i < asize; i++) {
prarr.set(i, 0);
}

for (size_t i = 0; i < asize; i++) {
cout << prarr.get(i);
if (i < asize - 1) cout << " ";
}
cout << endl;
}

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

ifstream in(argv[1]);
if (!in.is_open()) {
return 1;
}

size_t size4;
in >> size4;

if (size4 > 0) {
Array arr4(size4);

for (size_t i = 0; i < size4; i++) {
Data value;
in >> value;
arr4.set(i, value);
}

task4(arr4);
}

size_t size5;
in >> size5;

if (size5 > 0) {
Array arr5(size5);

for (size_t i = 0; i < size5; i++) {
Data value;
in >> value;
arr5.set(i, value);
}

Data a, b;
in >> a >> b;

task5(arr5, a, b);
}

in.close();
return 0;
}
29 changes: 29 additions & 0 deletions Lab2CPPClass/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
add_executable(lab2cppclass Lab21Struct.cpp stack.cpp vector.cpp)
target_include_directories(lab2cppclass PUBLIC ../LibraryCPPClass)

add_test(NAME TestPlus COMMAND lab2cppclass "${CMAKE_CURRENT_SOURCE_DIR}/test_plus.txt" "${CMAKE_CURRENT_SOURCE_DIR}/input_empty.txt")
set_property(TEST TestPlus PROPERTY PASS_REGULAR_EXPRESSION "C")

add_test(NAME TestMinus COMMAND lab2cppclass "${CMAKE_CURRENT_SOURCE_DIR}/test_minus.txt" "${CMAKE_CURRENT_SOURCE_DIR}/input_empty.txt")
set_property(TEST TestMinus PROPERTY PASS_REGULAR_EXPRESSION "B")

add_test(NAME TestLeft COMMAND lab2cppclass "${CMAKE_CURRENT_SOURCE_DIR}/test_left.txt" "${CMAKE_CURRENT_SOURCE_DIR}/input_empty.txt")
set_property(TEST TestLeft PROPERTY PASS_REGULAR_EXPRESSION "A")

add_test(NAME TestRight COMMAND lab2cppclass "${CMAKE_CURRENT_SOURCE_DIR}/test_right.txt" "${CMAKE_CURRENT_SOURCE_DIR}/input_empty.txt")
set_property(TEST TestRight PROPERTY PASS_REGULAR_EXPRESSION "B")

add_test(NAME TestInput COMMAND lab2cppclass "${CMAKE_CURRENT_SOURCE_DIR}/test_input.txt" "${CMAKE_CURRENT_SOURCE_DIR}/input_test.txt")
set_property(TEST TestInput PROPERTY PASS_REGULAR_EXPRESSION "Z")

add_test(NAME TestOutput COMMAND lab2cppclass "${CMAKE_CURRENT_SOURCE_DIR}/test_output.txt" "${CMAKE_CURRENT_SOURCE_DIR}/input_empty.txt")
set_property(TEST TestOutput PROPERTY PASS_REGULAR_EXPRESSION "A")

add_test(NAME TestDuplicate COMMAND lab2cppclass "${CMAKE_CURRENT_SOURCE_DIR}/test_duplicate.txt" "${CMAKE_CURRENT_SOURCE_DIR}/input_empty.txt")
set_property(TEST TestDuplicate PROPERTY PASS_REGULAR_EXPRESSION "A")

add_test(NAME TestSwap COMMAND lab2cppclass "${CMAKE_CURRENT_SOURCE_DIR}/test_swap.txt" "${CMAKE_CURRENT_SOURCE_DIR}/input_empty.txt")
set_property(TEST TestSwap PROPERTY PASS_REGULAR_EXPRESSION "A")

add_test(NAME TestReverse COMMAND lab2cppclass "${CMAKE_CURRENT_SOURCE_DIR}/test_reverse.txt" "${CMAKE_CURRENT_SOURCE_DIR}/input_empty.txt")
set_property(TEST TestReverse PROPERTY PASS_REGULAR_EXPRESSION "A")
Loading