diff --git a/Homework_STL/Homework_STL.sln b/Homework_STL/Homework_STL.sln new file mode 100644 index 0000000..e952ea7 --- /dev/null +++ b/Homework_STL/Homework_STL.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32630.192 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Homework_STL", "Homework_STL\Homework_STL.vcxproj", "{10BC67F6-E670-4CC5-B009-66534138C23D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {10BC67F6-E670-4CC5-B009-66534138C23D}.Debug|x64.ActiveCfg = Debug|x64 + {10BC67F6-E670-4CC5-B009-66534138C23D}.Debug|x64.Build.0 = Debug|x64 + {10BC67F6-E670-4CC5-B009-66534138C23D}.Debug|x86.ActiveCfg = Debug|Win32 + {10BC67F6-E670-4CC5-B009-66534138C23D}.Debug|x86.Build.0 = Debug|Win32 + {10BC67F6-E670-4CC5-B009-66534138C23D}.Release|x64.ActiveCfg = Release|x64 + {10BC67F6-E670-4CC5-B009-66534138C23D}.Release|x64.Build.0 = Release|x64 + {10BC67F6-E670-4CC5-B009-66534138C23D}.Release|x86.ActiveCfg = Release|Win32 + {10BC67F6-E670-4CC5-B009-66534138C23D}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {609D2169-0704-4381-9721-F22E05813CA4} + EndGlobalSection +EndGlobal diff --git a/Homework_STL/Homework_STL/Color.h b/Homework_STL/Homework_STL/Color.h new file mode 100644 index 0000000..874c932 --- /dev/null +++ b/Homework_STL/Homework_STL/Color.h @@ -0,0 +1,43 @@ +#pragma once + +enum colors { + white, + yellow, + azure, + red, + blue, + violet, + green, + violet_dark, + blue_dark, + gray_dark, +}; + +class color { +private: + colors type; + +public: + color() : type(colors::white) {}; + color(colors _type) : type(_type) {}; + friend std::ostream& operator << (std::ostream& os, const color& color) { + HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); + color.type == white ? SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE) : + color.type == yellow ? SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY) : + color.type == azure ? SetConsoleTextAttribute(hStdout, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY) : + color.type == red ? SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_INTENSITY) : + color.type == blue ? SetConsoleTextAttribute(hStdout, FOREGROUND_BLUE | FOREGROUND_INTENSITY) : + color.type == violet ? SetConsoleTextAttribute(hStdout, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE) : + color.type == green ? SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN | FOREGROUND_INTENSITY) : + color.type == violet_dark ? SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_INTENSITY | FOREGROUND_BLUE) : + color.type == blue_dark ? SetConsoleTextAttribute(hStdout, FOREGROUND_BLUE | FOREGROUND_GREEN) : + color.type == gray_dark ? SetConsoleTextAttribute(hStdout, FOREGROUND_INTENSITY) : + NULL; + return os; + } + + std::string print(std::string word) { + std::cout << color(type) << word << color(); + return ""; + } +}; diff --git a/Homework_STL/Homework_STL/Homework_STL.vcxproj b/Homework_STL/Homework_STL/Homework_STL.vcxproj new file mode 100644 index 0000000..0de747c --- /dev/null +++ b/Homework_STL/Homework_STL/Homework_STL.vcxproj @@ -0,0 +1,140 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {10bc67f6-e670-4cc5-b009-66534138c23d} + HomeworkSTL + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Homework_STL/Homework_STL/Homework_STL.vcxproj.filters b/Homework_STL/Homework_STL/Homework_STL.vcxproj.filters new file mode 100644 index 0000000..431d201 --- /dev/null +++ b/Homework_STL/Homework_STL/Homework_STL.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + \ No newline at end of file diff --git a/TestProject/TestProject/TestProject.vcxproj.user b/Homework_STL/Homework_STL/Homework_STL.vcxproj.user similarity index 100% rename from TestProject/TestProject/TestProject.vcxproj.user rename to Homework_STL/Homework_STL/Homework_STL.vcxproj.user diff --git a/Homework_STL/Homework_STL/Main_STL.cpp b/Homework_STL/Homework_STL/Main_STL.cpp new file mode 100644 index 0000000..5798517 --- /dev/null +++ b/Homework_STL/Homework_STL/Main_STL.cpp @@ -0,0 +1,76 @@ +#include "Menu.h" +#include "Tasker.h" + +int main() { + srand(time(NULL)); + Answer answer; + Menu menu; + Tasker tasker; + menu.Blinking(FALSE); + + while (true) { + answer = menu.Enable(); + menu.reset_iKey(); + if (answer.iKey == KEY_EXIT || answer.choose == ITEMS::exit) { + system("cls"); + std::cout << color(red).print("Exit program!"); + _getch(); + break; + } + else if (answer.choose == ITEMS::btn1) { + system("cls"); + tasker.test(answer.iterator); + _getch(); + system("cls"); + } + else if (answer.choose == ITEMS::btn2) { + if (answer.iterator == 0 || answer.iterator == 1 || answer.iterator == 3) { + system("cls"); + tasker.analysis(answer.iterator); + _getch(); + system("cls"); + } + else if (answer.iterator == 2) { + while (true) { + menu.type_switch(TYPE::stack); + system("cls"); + answer = menu.Enable(); + if (answer.iKey == KEY_EXIT || answer.choose == ITEMS::exit) { + system("cls"); + std::cout << color(red).print("Exit stack menu!"); + menu.type_switch(TYPE::main); + break; + } + else if (answer.choose == ITEMS::btn1) { + system("cls"); + std::cout << color(yellow).print("Add element"); + tasker.t3.push(answer.value); + _getch(); + } + else if (answer.choose == ITEMS::btn2) { + system("cls"); + if (tasker.t3.stack.empty()) { std::cout << color(yellow).print("Stack is clear!"); } + else { std::cout << color(yellow) << "Element deleted: " << color(azure) << tasker.t3.stack.top() << color(); } + tasker.t3.pop(); + _getch(); + } + else if (answer.choose == ITEMS::btn3) { + system("cls"); + tasker.t3.print(); + _getch(); + } + else if (answer.choose == ITEMS::btn4) { + system("cls"); + std::cout << color(yellow).print("Cleared!"); + tasker.t3.clear(); + _getch(); + } + } + _getch(); + system("cls"); + } + } + } + return 0; +} + diff --git a/Homework_STL/Homework_STL/Menu.h b/Homework_STL/Homework_STL/Menu.h new file mode 100644 index 0000000..c0b9090 --- /dev/null +++ b/Homework_STL/Homework_STL/Menu.h @@ -0,0 +1,300 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Color.h" + +int lenghtNUM(int val); + +#define KEY_EXIT 27 +#define KEY_ENTER 13 +#define ARROW_KEY 224 +#define KEY_SPACE 0 +#define KEY_BACKSPACE 8 + + +#define KEY_ARROW_RIGHT 77 +#define KEY_ARROW_LEFT 75 +#define KEY_ARROW_UP 72 +#define KEY_ARROW_DOWN 80 + +#define KEY_0 0x30 +#define KEY_1 0x31 +#define KEY_2 0x32 +#define KEY_3 0x33 +#define KEY_4 0x34 +#define KEY_5 0x35 +#define KEY_6 0x36 +#define KEY_7 0x37 +#define KEY_8 0x38 +#define KEY_9 0x39 + +#define KEY_MINUS 45 + +enum class ITEMS : int { none, btn1, btn2, btn3, btn4, exit }; +enum class TYPE : int { main, stack }; + +int blockUP = 2; +int blockDOWN = 2; + +inline ITEMS operator++ (ITEMS& item, int postfix) { + if (blockUP == 4) { + return (int)item > blockUP ? ITEMS::btn1 : (ITEMS)((int)(item)+1); + } + else if (blockUP == 2) { + return (int)item > blockUP ? ITEMS::btn1 : item == ITEMS::btn2 ? item = ITEMS::exit : (ITEMS)((int)(item)+1); + } +} +inline ITEMS operator-- (ITEMS& item, int postfix) { + if (blockUP == 4) { + return (int)item < blockDOWN ? ITEMS::exit : (ITEMS)((int)(item)-1); + } + else if (blockUP == 2) { + return (int)item < blockDOWN ? ITEMS::exit : item == ITEMS::exit ? item = ITEMS::btn2 : (ITEMS)((int)(item)-1); + } +} + +struct Answer { + HANDLE hStdOut; + COORD cursorPos, startPos; + ITEMS choose; + TYPE type; + int iKey, vSize, iterator, value; +}; + +class Menu { +private: + std::vector test_btn; + std::vector detail_btn; + Answer answer; +public: + + Menu() { + answer.choose = ITEMS::btn1; + answer.iKey = 67; + answer.vSize = 50; + answer.iterator = 0; + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + answer.hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); + answer.cursorPos.X = answer.startPos.X = 0; + answer.cursorPos.Y = answer.startPos.Y = 0; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + test_btn.push_back("One"); + test_btn.push_back("Two"); + test_btn.push_back("Three"); + test_btn.push_back("Four"); + detail_btn.push_back("One"); + detail_btn.push_back("Two"); + detail_btn.push_back("Three"); + detail_btn.push_back("Four"); + answer.type = TYPE::main; + answer.value = 0; + } + + Menu(const Menu& menu) { + answer.choose = menu.answer.choose; + answer.iKey = menu.answer.iKey; + answer.vSize = menu.answer.vSize; + answer.iterator = menu.answer.iterator; + answer.hStdOut = menu.answer.hStdOut; + answer.cursorPos = menu.answer.cursorPos; + answer.startPos = menu.answer.startPos; + test_btn = menu.test_btn; + answer.type = menu.answer.type; + answer.value = menu.answer.value; + } +private: + void DrawButtons() { + if (answer.type == TYPE::main) { + answer.cursorPos = { 5, 0 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << (answer.choose == ITEMS::btn1 ? color(blue) : color(gray_dark)) << "Summary of the task test " << color() << std::endl; + answer.cursorPos = { 5, 1 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << (answer.choose == ITEMS::btn2 ? color(blue) : color(gray_dark)) << "Detailed analysis of task" << color() << std::endl; + answer.cursorPos = { 5, 2 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << (answer.choose == ITEMS::exit ? color(red) : color(gray_dark)) << "Exit from program" << color() << std::endl; + } + else if (answer.type == TYPE::stack) { + answer.cursorPos = { 5, 0 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << (answer.choose == ITEMS::btn1 ? color(blue) : color(gray_dark)) << "Push element " << color() << std::endl; + answer.cursorPos = { 5, 1 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << (answer.choose == ITEMS::btn2 ? color(blue) : color(gray_dark)) << "Pop element " << color() << std::endl; + answer.cursorPos = { 5, 2 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << (answer.choose == ITEMS::btn3 ? color(blue) : color(gray_dark)) << "Print element " << color() << std::endl; + answer.cursorPos = { 5, 3 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << (answer.choose == ITEMS::btn4 ? color(blue) : color(gray_dark)) << "Clear elements " << color() << std::endl; + answer.cursorPos = { 5, 4 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << (answer.choose == ITEMS::exit ? color(red) : color(gray_dark)) << "Exit from stack menu " << color() << std::endl; + } + } + + void DrawArrows() { + if (answer.type == TYPE::main) { + if (answer.choose == ITEMS::btn1) { + answer.cursorPos = { 1, 0 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << color(azure).print(">>"); + answer.cursorPos = { 30, 0 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << color(azure).print("[" + test_btn[answer.iterator] + "]"); + } + else if (answer.choose == ITEMS::btn2) { + answer.cursorPos = { 1, 1 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << color(azure).print(">>"); + answer.cursorPos = { 31, 1 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << color(azure).print("[" + detail_btn[answer.iterator] + "]"); + } + else if (answer.choose == ITEMS::exit) { + answer.cursorPos = { 1, 2 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << color(red).print(">>"); + } + } + else if (answer.type == TYPE::stack) { + if (answer.choose == ITEMS::btn1) { + answer.cursorPos = { 1, 0 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << color(azure).print(">>"); + answer.cursorPos = { 18, 0 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << color(azure).print("[" + std::to_string(answer.value) + "]"); + } + else if (answer.choose == ITEMS::btn2) { + answer.cursorPos = { 1, 1 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << color(azure).print(">>"); + } + if (answer.choose == ITEMS::btn3) { + answer.cursorPos = { 1, 2 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << color(azure).print(">>"); + } + else if (answer.choose == ITEMS::btn4) { + answer.cursorPos = { 1, 3 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << color(azure).print(">>"); + } + else if (answer.choose == ITEMS::exit) { + answer.cursorPos = { 1, 4 }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << color(red).print(">>"); + } + } + } + + void Draw() { + DrawButtons(); + DrawArrows(); + answer.cursorPos = { 0, 0 }; + } + +public: + void Blinking(bool flag) { + CONSOLE_CURSOR_INFO structCursorInfo; + GetConsoleCursorInfo(answer.hStdOut, &structCursorInfo); + flag == false ? structCursorInfo.bVisible = FALSE : structCursorInfo.bVisible = TRUE; + SetConsoleCursorInfo(answer.hStdOut, &structCursorInfo); + } + Answer Enable() { + while (answer.iKey != KEY_EXIT && answer.iKey != KEY_ENTER) { + if (answer.type == TYPE::main) { + if (answer.iKey == KEY_ARROW_LEFT) { + if (answer.choose == ITEMS::btn1 || answer.choose == ITEMS::btn2) answer.iterator > 0 ? answer.iterator-- : answer.iterator = 3; + } + else if (answer.iKey == KEY_ARROW_RIGHT) { + if (answer.choose == ITEMS::btn1 || answer.choose == ITEMS::btn2) answer.iterator < 3 ? answer.iterator++ : answer.iterator = 0; + } + else if (answer.iKey == KEY_ARROW_UP) answer.choose = answer.choose--; + else if (answer.iKey == KEY_ARROW_DOWN) answer.choose = answer.choose++; + clear_buffers_part(); + } + else if (answer.type == TYPE::stack) { + if ((num1_9pressed()) && lenghtNUM(answer.value) < 9) { + int minus = answer.value < 0 ? -1 : 1; + answer.value = minus * (abs(answer.value) * 10 + (static_cast(answer.iKey) - 48)); + } + else if (answer.iKey == VK_SPACE) { + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<> Random(-999999999, 999999999); + answer.value = Random(gen); + } + else if (answer.iKey == KEY_MINUS) { answer.value = answer.value * (-1); } + else if (answer.iKey == KEY_BACKSPACE) { answer.value = (answer.value - answer.value % 10) * 0.1; } + else if (answer.iKey == KEY_ARROW_UP) answer.choose = answer.choose--; + else if (answer.iKey == KEY_ARROW_DOWN) answer.choose = answer.choose++; + clear_buffers_part(); + } + Draw(); + answer.iKey = _getch(); + } + return answer; + } + + void reset_iKey() { + answer.iKey = 67; + } + + void clear_buffers_part() { + for (short i = 0; i < 5; i++) { + answer.cursorPos = { 0, i }; + SetConsoleCursorPosition(answer.hStdOut, answer.cursorPos); + std::cout << " " << std::endl; + } + } + + void type_switch(TYPE _type) { + answer.type = _type; + reset_iKey(); + answer.iterator = 0; + if (answer.type == TYPE::main) { + blockUP = 2; + answer.choose = ITEMS::btn1; + } + else if (answer.type == TYPE::stack) { + blockUP = 4; + } + } + + bool num1_9pressed() { + for (int i = 0; i < 10; i++) { if (answer.iKey == static_cast(i) + 48) { return true; } } + return false; + } +}; + +int lenghtNUM(int val) { + auto l = [&val]() { + int buffer_print = 0; + if (val < 0) { + buffer_print++; + val = abs(val); + } + while (val > 0) { + buffer_print++; + val = (val - val % 10) * 0.1; + } + return buffer_print; + }; + return val == 0 ? 1 : l(); +} diff --git a/Homework_STL/Homework_STL/Tasker.h b/Homework_STL/Homework_STL/Tasker.h new file mode 100644 index 0000000..f328078 --- /dev/null +++ b/Homework_STL/Homework_STL/Tasker.h @@ -0,0 +1,904 @@ +#pragma once +#include "Menu.h" + +struct task_1 { + std::vector vector; + void create(int count) { vector = std::vector(count, 0); } + void rundom_fill() { for (auto& elem : vector) { elem = rand() % 201 - 100; } } + void print_vector(bool flag) { + if (flag) { + std::cout << ": { "; + for (auto it = begin(vector); it != end(vector); it++) { + std::cout << *it; + if (it != end(vector) - 1) { + std::cout << ", "; + } + } + std::cout << " } \n"; + } + else { + std::cout << ": { "; + for (auto it = rbegin(vector); it != rend(vector); it++) { + std::cout << *it; + if (it != rend(vector) - 1) { + std::cout << ", "; + } + } + std::cout << " } \n"; + } + } + void max_min_elem() { + std::cout << + ": { min: " << + *std::min_element(begin(vector), end(vector)) << ", max: " << + *std::max_element(begin(vector), end(vector)) << " } \n"; + } + void sorting() { sort(begin(vector), end(vector)); } + void insert4numbers() { for (int i = 0; i < 4; i++) { vector.push_back(rand() % 201 - 100); } } + void less10to0() { for (auto& elem : vector) { elem < 10 ? elem = 0 : elem; } } + void more20() { + byte flag = 0; + std::cout << ": { "; + for (auto& elem : vector) { + if (flag == 1 && elem > 20) { + std::cout << " , "; + } + if (elem > 20) { + flag == 0 ? flag = 1 : flag; + std::cout << elem; + } + } + std::cout << " } \n"; + } + void mult3() { for (auto& elem : vector) { elem & 1 ? elem : elem *= 3; } } + void rundom_shuffle() { std::random_shuffle(begin(vector), end(vector)); } + void delete50() { + for (auto& elem : vector) { + for (auto it = begin(vector); it != end(vector); it++) { + if (*it > 50) { + vector.erase(it); + break; + } + } + } + } + void elemen_count() { + if (vector.size() & 1) { + vector.pop_back(); + std::cout << ": {count: " << vector.size() << " }"; + print_vector(true); + } + else { + std::cout << ": {count: " << vector.size() << " }"; + print_vector(false); + } + } + void cleaner() { vector.clear(); } +}; + +struct task_2 { + std::list list; + void print_list() { + int i = 0; + std::cout << " : { "; + for (auto& elem : list) { + i++; + std::cout << elem; + if (i != list.size()) { + std::cout << ", "; + } + } + std::cout << " } \n"; + } + void add_back5() { for (int i = 0; i < 5; i++) { list.push_back(rand() % 201 - 100); } } + void print_first() { std::cout << " : {first: " << list.front() << " }"; } + void add_front2() { for (int i = 0; i < 2; i++) { list.push_front(rand() % 201 - 100); } } + void delete4elem() { + int i = 0; + for (auto it = begin(list); it != end(list); it++) { + i++; + if (i == 4) { + list.erase(it); + break; + } + } + } + void _3randpos3elem() { + int element = rand() % 201 - 100; + int size = list.size(); + std::cout << " : {position: "; + for (int i = 0, j = 0; i < 3; i++) { + int pos = rand() % size; + if (i != 2) { std::cout << pos << ", "; } + else { std::cout << pos << " }"; } + for (auto& elem : list) { j++ == pos ? elem = element : elem; } + j = 0; + } + } + void del_last() { list.pop_back(); } + void del_first() { list.pop_front(); } + void insert_to_center() { + int i = 0; + for (auto it = begin(list); it != end(list); it++) { + if (i == floor(list.size() * 0.5)) { + list.insert(it, { rand() % 201 - 100, rand() % 201 - 100 }); + break; + } + i++; + } + } + void del_dublicate() { + bool breaker = false; + int number; + int counter = 0; + while (true) { + for (auto it = begin(list); it != end(list); it++) { + number = *it; + for (auto ita = begin(list); ita != end(list); ita++) { + if (*ita == number) { + counter++; + if (counter > 1) { + list.erase(ita); + counter = 0; + breaker = true; + break; + } + } + } + if (breaker) { + breaker = 0; + break; + } + counter = 0; + } + if (unique(list)) break; + } + } + void cleaner() { list.clear(); } + void if_clean() { if (list.empty()) { std::cout << " : { CLEAN! }"; } } + + bool unique(std::list _list) { + int number; + int counter = 0; + for (auto it = begin(_list); it != end(_list); it++) { + number = *it; + for (auto ita = begin(_list); ita != end(_list); ita++) { + if (*ita == number) { + counter++; + if (counter > 1) { + return false; + } + } + } + counter = 0; + } + return true; + } +}; + +struct task_3 { + std::stack stack; + void push(int value) { stack.push(value); } + void pop() { stack.empty() ? void() : stack.pop(); } + void print() { + std::stack buffer; + int prnt = prtnt_bff(); + if (!(stack.empty())) std::cout << std::left << std::setw(3 + floor(prnt - 3 * 0.5)) << color(yellow) << "| " << "..." << std::right << std::setw(3 + ceil(prnt - 3 * 0.5)) << color(yellow) << " |\n" << color(); + for (int i = 0;stack.size() > 0; i++) { + int flag_minus = 0; + stack.top() < 0 && lenghtNUM(abs(stack.top())) & 1 ? flag_minus = 1 : flag_minus = 0; + std::cout << std::left << std::setw(3 - flag_minus + floor(prnt - lenghtNUM(stack.top()) * 0.5)) << color(yellow) << "| " << color(azure) << stack.top() << color() << std::right << std::setw(2 + flag_minus + ceil(prnt - lenghtNUM(stack.top()) * 0.5)) << color(yellow) << " |" << color() << std::endl; + buffer.push(stack.top()); + stack.pop(); + } + for (; buffer.size() > 0;) { + stack.push(buffer.top()); + buffer.pop(); + } + if (stack.empty()) std::cout << color(yellow).print("Stack is clear!"); + else { + for (int i = 0; i < floor(prnt * 0.5) + ceil(prnt * 0.5) + prnt + 5; i++) { + std::cout << color(yellow).print("-"); + } + } + + } + std::string print_(int prnt) { + for (int i = 0; i < prnt; i++) { std::cout << " "; }; + return ""; + } + void clear() { for (; stack.size() > 0;) { stack.pop(); } } + + int prtnt_bff() { + int buffer_print = 0; + int ret_pr = 0; + std::vector rp; + std::stack stbf; + for (; stack.size() > 0;) { + int buffer_num = abs(stack.top()); + buffer_num == 0 ? buffer_num = 1 : NULL; + while (buffer_num > 0) { + buffer_print++; + buffer_num = (buffer_num - buffer_num % 10) * 0.1; + } + buffer_print > ret_pr ? ret_pr = buffer_print : NULL; + buffer_print = 0; + stbf.push(stack.top()); + stack.pop(); + } + for (; stbf.size() > 0;) { + stack.push(stbf.top()); + stbf.pop(); + } + return ret_pr; + } +}; + +struct task_4 { + std::set A; + std::set B; + void generation(std::set &set) { for (auto elem : {1, 2, 3, 4, 5, 6, 7}) { set.insert(rand() % 10 + 1); } } + void print(std::set set, bool f) { + int i = 0; + std::cout << " : { "; + for (auto& elem : set) { + i++; + std::cout << elem; + if (i != set.size()) { + std::cout << ", "; + } + } + std::cout << " }"; + if (f) std::cout << "\n"; + } + void intersection() { + std::set bf_set; + for (auto& elem : A) { for (auto& _elem : B) { if (elem == _elem) { bf_set.insert(elem); } } } + print(bf_set, true); + } + void unite() { + std::set bf_set = B; + for (auto& elem : A) { + bf_set.insert(elem); + } + print(bf_set, true); + } + void difference() { + std::set bf_set; + bool flag = false; + for (auto& elem : A) { + for (auto& _elem : B) { + if (elem == _elem) { + flag = true; + } + } + if (!flag) bf_set.insert(elem); + flag = false; + } + for (auto& elem : B) { + for (auto& _elem : A) { + if (elem == _elem) { + flag = true; + } + } + if (!flag) bf_set.insert(elem); + flag = false; + } + print(bf_set, true); + } + void univers(std::set _set) { + std::set bf_set; + bool flag = false; + for (auto& elem : {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + for (auto& _elem : _set) { + if (elem == _elem) { + flag = true; + } + } + if (!flag) bf_set.insert(elem); + flag = false; + } + print(bf_set, true); + } + void cleaner() { + A.clear(); + B.clear(); + } +}; + +class Tasker { +private:task_1 t1; +private:task_2 t2; +public: task_3 t3; +private:task_4 t4; + +public: + Tasker() { + t1 = task_1(); + t2 = task_2(); + t3 = task_3(); + t4 = task_4(); + } + + void test(int choose) { choose == 0 ? atest_1() : choose == 1 ? atest_2() : choose == 2 ? atest_3() : atest_4(); } + + void atest_1() { + //=========================================== + // Step test 1 + bool passed = true; + task_1 testVector; + // test + testVector.vector = std::vector(20, 0); + + // task + t1.create(20); + + // testing + if (testVector.vector.size() == t1.vector.size()) { + int size = testVector.vector.size(); + for (int i = 0; i < size; i++) { + testVector.vector[i] == t1.vector[i] ? NULL : passed = false; + } + } + else { passed = false; } + std::cout << (true ? color(azure).print(" : 20 , \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 1 : ") : ""); + //=========================================== + // Step test 2 + passed = false; + // test + testVector = t1; + // task + t1.rundom_fill(); + + // testing + if (testVector.vector.size() == t1.vector.size() && t1.vector.size() != 0) { + int size = testVector.vector.size(); + for (int i = 0; i < size; i++) { + testVector.vector[i] == t1.vector[i] ? NULL : passed = true; + } + } + else if (t1.vector.size() == 0 && testVector.vector.size() == 0) { passed = true; } + std::cout << (true ? color(azure).print(" : ( -100, 100)\n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 2 : ") : ""); + testVector = t1; + //=========================================== + // Step test 3 + passed = false; + int min = 100, max = -100; + // test + testVector = t1; + // task + for (int i = 0; i < testVector.vector.size(); i++) { + if (testVector.vector[i] < min) min = testVector.vector[i]; + if (testVector.vector[i] > max) max = testVector.vector[i]; + } + // testing + int _max = *std::max_element(begin(t1.vector), end(t1.vector)); + int _min = *std::min_element(begin(t1.vector), end(t1.vector)); + + if (min == _min && max == _max ) { passed = true; } + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 3 : ") : ""); + //=========================================== + // Step test 4 + testVector = t1; + passed = true; + // task + t1.sorting(); + // testing + for (int i = 0; i < t1.vector.size() - 1; i++) { t1.vector[i] <= t1.vector[i + 1] ? passed : passed = false; } + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 4 : ") : ""); + //=========================================== + // Step test 5 + passed = true; + // test + testVector = t1; + // task + t1.insert4numbers(); + // testing + testVector.vector.size() == t1.vector.size() - 4 ? NULL : passed = !passed; + std::cout << (true ? color(azure).print(" : 4- \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 5 : ") : ""); + //=========================================== + // Step test 6 + passed = true; + // test + testVector = t1; + // task + t1.less10to0(); + // testing + for (int i = 0; i < t1.vector.size(); i++) { t1.vector[i] == 0 ? testVector.vector[i] < 10 ? NULL : passed = false : NULL; } + std::cout << (true ? color(azure).print(" : 10- 0\n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 6 : ") : ""); + //=========================================== + // Step test 7 + passed = false; + // test + testVector = t1; + // task + for (int i = 0; i < t1.vector.size(); i++) { t1.vector[i] > 20 ? passed = true : NULL; } + std::cout << (true ? color(azure).print(" : 20\n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 7 : ") : ""); + // testing + //=========================================== + // Step test 8 + passed = true; + // test + testVector = t1; + // task + t1.mult3(); + // testing + for (int i = 0; i < t1.vector.size(); i++) { !(testVector.vector[i] & 1) ? t1.vector[i] == testVector.vector[i] * 3 ? NULL : passed = false : NULL; } + std::cout << (true ? color(azure).print(" : 3\n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 8 : ") : ""); + //=========================================== + // Step test 9 + passed = false; + // test + testVector = t1; + // task + t1.rundom_shuffle(); + // testing + for (int i = 0; i < t1.vector.size(); i++) { testVector.vector[i] != t1.vector[i] ? passed = true : NULL; } + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 9 : ") : ""); + //=========================================== + // Step test 10 + passed = false; + bool t = false; + // test + testVector = t1; + // task + t1.delete50(); + // testing + for (int i = 0; i < testVector.vector.size(); i++) { testVector.vector[i] > 50 ? t = true : NULL; } + t ? testVector.vector.size() != t1.vector.size() ? passed = true : NULL : passed = true; + std::cout << (true ? color(azure).print(" : 50\n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 10 : ") : ""); + //=========================================== + // Step test 11 + passed = true; + // test + testVector = t1; + // task + std::cout << (true ? color(azure).print(" : - \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 11 : ") : ""); + // testing + //=========================================== + // Step test 12 + passed = true; + // test + testVector = t1; + // task + t1.cleaner(); + // testing + t1.vector.empty() ? NULL : passed = !passed; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 12 : ") : ""); + } + + void atest_2() { + bool passed = true; + task_2 testList; + //=========================================== + // Step test 1 + passed = true; + // test + testList = t2; + // task + t2 = task_2(); + // testing + t2.list.empty() && testList.list.empty() ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 1 : ") : ""); + //=========================================== + // Step test 2 + passed = true; + // test + testList = t2; + // task + t2.add_back5(); + // testing + t2.list.size() == testList.list.size() + 5 ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : 5 \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 2 : ") : ""); + //=========================================== + // Step test 3 + passed = true; + // test + testList = t2; + // task + // testing + t2.list.front() == testList.list.front() ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 3 : ") : ""); + //=========================================== + // Step test 4 + passed = true; + // test + testList = t2; + // task + t2.add_front2(); + // testing + t2.list.size() == testList.list.size() + 2 ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : 2 \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 4 : ") : ""); + //=========================================== + // Step test 5 + passed = true; + // test + testList = t2; + // task + t2.delete4elem(); + // testing + t2.list.size() + 1 == testList.list.size() ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : 4- \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 5 : ") : ""); + //=========================================== + // Step test 6 + passed = true; + // test + testList = t2; + // task + //t2._3randpos3elem(); + auto f = [&](task_2 t2) { + int element = rand() % 201 - 100; + int size = t2.list.size(); + for (int i = 0, j = 0; i < 3; i++) { + int pos = rand() % size; + for (auto& elem : t2.list) { j++ == pos ? elem = element : elem; } + j = 0; + } + }; + f(t2); + // testing + for (int i = 0; i < t2.list.size(); i++) { + int a = 0, b = 0, c = 0; + for (auto& elem : t2.list) { + if (c == i) { + a = elem; + c = 0; + break; + } + c++; + } + for (auto& elem : testList.list) { + if (c == i) { + b = elem; + c = 0; + break; + } + c++; + } + a != b ? passed = false : NULL; + } + std::cout << (true ? color(azure).print(" : 3 \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 6 : ") : ""); + //=========================================== + // Step test 7 + passed = true; + // test + testList = t2; + // task + t2.del_last(); + // testing + t2.list.size() + 1 == testList.list.size() ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 7 : ") : ""); + //=========================================== + // Step test 8 + passed = true; + // test + testList = t2; + // task + t2.del_last(); + // testing + t2.list.size() + 1 == testList.list.size() ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 8 : ") : ""); + //=========================================== + // Step test 9 + passed = true; + // test + testList = t2; + // task + t2.insert_to_center(); + // testing + t2.list.size() == testList.list.size() + 2 ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : 2 \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 9 : ") : ""); + //=========================================== + // Step test 10 + passed = true; + // test + testList = t2; + // task + t2.del_dublicate(); + // testing + auto funique = [&](task_2 t2) { + int number; + int counter = 0; + for (auto it = begin(t2.list); it != end(t2.list); it++) { + number = *it; + for (auto ita = begin(t2.list); ita != end(t2.list); ita++) { + if (*ita == number) { + counter++; + if (counter > 1) { + return false; + } + } + } + counter = 0; + } + return true; + }; + funique(t2) ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 10 : ") : ""); + //=========================================== + // Step test 11 + passed = true; + // test + testList = t2; + // task + t2.cleaner(); + // testing + t2.list.empty() ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 11 : ") : ""); + //=========================================== + // Step test 12 + passed = true; + // test + // task + // testing + t2.list.empty() ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 12 : ") : ""); + } + + void atest_3() { + //=========================================== + // Step test 1 + bool passed = true; + task_3 testStack; + // test + testStack = t3; + + // task + t3.push(1); + + // testing + t3.stack.size() == testStack.stack.size() + 1 ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 1 : ") : ""); + //=========================================== + // Step test 2 + passed = true; + // test + testStack = t3; + + // task + t3.pop(); + + // testing + t3.stack.size() + 1 == testStack.stack.size() ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 2 : ") : ""); + //=========================================== + // Step test 3 + passed = true; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 3 : ") : ""); + //=========================================== + // Step test 4 + passed = true; + // test + testStack = t3; + + // task + t3.clear(); + + // testing + t3.stack.empty() ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 4 : ") : ""); + } + + void atest_4() { + //=========================================== + // Step test 1 + bool passed = true; + task_4 testStack; + // test + testStack = t4; + // task + t4.generation(t4.A); + // testing + !(t4.A.empty()) ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : A\n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 1 : ") : ""); + //=========================================== + // Step test 2 + passed = true; + // test + testStack = t4; + // task + t4.generation(t4.B); + // testing + !(t4.A.empty()) ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : B\n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 2 : ") : ""); + //=========================================== + // Step test 3 + passed = true; + // test + testStack = t4; + // task + //t4.intersection(); + // testing + std::set bf_set; + for (auto& elem : t4.A) { for (auto& _elem : t4.B) { if (elem == _elem) { bf_set.insert(elem); } } } + bf_set.size() < t4.A.size() ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 3 : ") : ""); + //=========================================== + // Step test 4 + passed = true; + // test + testStack = t4; + // task + //t4.difference(); + // testing + std::set bf_set1; + for (auto& elem : t4.A) { for (auto& _elem : t4.B) { if (elem != _elem) { bf_set.insert(elem); } } } + bf_set1.size() < t4.A.size() ? NULL : passed = false; + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 4 : ") : ""); + //=========================================== + // Step test 5 + passed = true; + // test + testStack = t4; + // task + // testing + auto f = [](task_4 t4) { + std::set bf_set; + bool flag = false; + for (auto& elem : { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }) { + for (auto& _elem : t4.A) { + if (elem == _elem) { + flag = true; + } + } + if (!flag) bf_set.insert(elem); + flag = false; + } + return bf_set; + }; + for (auto& elem : t4.A) { for (auto& _elem : f(t4)) { elem != _elem ? NULL : passed = false; } } + std::cout << (true ? color(azure).print(" : \n") : "") << (passed ? color(green).print("[PASSED]") : color(red).print("[INVALID]")) << (true ? color(azure).print("Step 5 : ") : ""); + + } + + void analysis(int choose) { choose == 0 ? atask_1() : choose == 1 ? atask_2() : choose == 2 ? atask_3() : atask_4(); } + + void atask_1() { + // Step 1 + std::cout << color(blue).print("Step 1 ") << color(azure); + t1.create(20); + t1.print_vector(true); + // Step 2 + std::cout << color(blue).print("Step 2 ") << color(azure); + t1.rundom_fill(); + t1.print_vector(true); + // Step 3 + std::cout << color(blue).print("Step 3 ") << color(azure); + t1.max_min_elem(); + // Step 4 + std::cout << color(blue).print("Step 4 ") << color(azure); + t1.sorting(); + t1.print_vector(true); + // Step 5 + std::cout << color(blue).print("Step 5 ") << color(azure); + t1.insert4numbers(); + t1.print_vector(true); + // Step 6 + std::cout << color(blue).print("Step 6 ") << color(azure); + t1.less10to0(); + t1.print_vector(true); + // Step 7 + std::cout << color(blue).print("Step 7 ") << color(azure); + t1.more20(); + // Step 8 + std::cout << color(blue).print("Step 8 ") << color(azure); + t1.mult3(); + t1.print_vector(true); + // Step 9 + std::cout << color(blue).print("Step 9 ") << color(azure); + t1.rundom_shuffle(); + t1.print_vector(true); + // Step 10 + std::cout << color(blue).print("Step 10 ") << color(azure); + t1.delete50(); + t1.print_vector(true); + // Step 11 + std::cout << color(blue).print("Step 11 ") << color(azure); + t1.elemen_count(); + // Step 12 + std::cout << color(blue).print("Step 12 ") << color(azure); + t1.cleaner(); + t1.print_vector(true); + + } + + void atask_2() { + // Step 1 + std::cout << color(blue).print("Step 1 ") << color(azure); + t2.print_list(); + // Step 2 + std::cout << color(blue).print("Step 2 ") << color(azure); + t2.add_back5(); + t2.print_list(); + // Step 3 + std::cout << color(blue).print("Step 3 ") << color(azure); + t2.print_first(); + t2.print_list(); + // Step 4 + std::cout << color(blue).print("Step 4 ") << color(azure); + t2.add_front2(); + t2.print_list(); + // Step 5 + std::cout << color(blue).print("Step 5 ") << color(azure); + t2.delete4elem(); + t2.print_list(); + // Step 6 + std::cout << color(blue).print("Step 6 ") << color(azure); + t2._3randpos3elem(); + t2.print_list(); + // Step 7 + std::cout << color(blue).print("Step 7 ") << color(azure); + t2.del_last(); + t2.print_list(); + // Step 8 + std::cout << color(blue).print("Step 8 ") << color(azure); + t2.del_first(); + t2.print_list(); + // Step 9 + std::cout << color(blue).print("Step 9 ") << color(azure); + t2.insert_to_center(); + t2.print_list(); + // Step 10 + std::cout << color(blue).print("Step 10 ") << color(azure); + t2.del_dublicate(); + t2.print_list(); + // Step 11 + std::cout << color(blue).print("Step 11 ") << color(azure); + t2.cleaner(); + t2.print_list(); + // Step 12 + std::cout << color(blue).print("Step 12 ") << color(azure); + t2.if_clean(); + t2.print_list(); + } + + void atask_3() { + + } + + void atask_4() { + // Step 1 + std::cout << color(blue).print("Step 1 ") << color(azure); + t4.generation(t4.A); + std::cout << " [A]"; + t4.print(t4.A, true); + // Step 2 + std::cout << color(blue).print("Step 2 ") << color(azure); + t4.generation(t4.B); + std::cout << " [B]"; + t4.print(t4.B, true); + // Step 3 + std::cout << color(blue).print("Step 3 ") << color(azure); + std::cout << " [A & B]"; + t4.intersection(); + // Step 4 + std::cout << color(blue).print("Step 4 ") << color(azure); + std::cout << " [A || B]"; + t4.unite(); + // Step 5 + std::cout << color(blue).print("Step 5 ") << color(azure); + std::cout << " [A dif B]"; + t4.difference(); + // Step 6 + std::cout << color(blue).print("Step 6 ") << color(azure); + std::cout << " [U || A]"; + t4.univers(t4.A); + // Step 6.1 + std::cout << color(blue).print("Step 6.1 ") << color(azure); + std::cout << " [U || B]"; + t4.univers(t4.B); + // Cleaner + t4.cleaner(); + } +}; + + +//: 4 (9:00 - 13:00) +//: 5 (13:00 - 18:00) +//: 3 (15:00 - 18:00) +//: 0 +//: 9 (9:00 - 18:00) +// 4 + 5 + 3 + 9 = 21 +// 14:30 + + \ No newline at end of file diff --git a/TestProject/TestProject/Debug/TestProject.exe.recipe b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.exe.recipe similarity index 64% rename from TestProject/TestProject/Debug/TestProject.exe.recipe rename to Homework_STL/Homework_STL/x64/Debug/Homework_STL.exe.recipe index c8f27fc..cd53db6 100644 --- a/TestProject/TestProject/Debug/TestProject.exe.recipe +++ b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.exe.recipe @@ -2,7 +2,7 @@ - C:\Users\stud2020\Desktop\Максимка\TestProject\Debug\TestProject.exe + D:\StudioProject\Homework_STL\x64\Debug\Homework_STL.exe diff --git a/Homework_STL/Homework_STL/x64/Debug/Homework_STL.ilk b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.ilk new file mode 100644 index 0000000..f20f1c2 Binary files /dev/null and b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.ilk differ diff --git a/Homework_STL/Homework_STL/x64/Debug/Homework_STL.log b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.log new file mode 100644 index 0000000..e023fec --- /dev/null +++ b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.log @@ -0,0 +1,16 @@ + Main_STL.cpp +D:\StudioProject\Homework_STL\Homework_STL\Menu.h(244,108): warning C4244: =: преобразование "double" в "int", возможна потеря данных +D:\StudioProject\Homework_STL\Homework_STL\Menu.h(295,36): warning C4244: =: преобразование "double" в "int", возможна потеря данных +D:\StudioProject\Homework_STL\Homework_STL\Tasker.h(108,1): warning C4267: инициализация: преобразование из "size_t" в "int"; возможна потеря данных +D:\StudioProject\Homework_STL\Homework_STL\Tasker.h(186,63): warning C4244: аргумент: преобразование "double" в "std::streamsize", возможна потеря данных +D:\StudioProject\Homework_STL\Homework_STL\Tasker.h(186,152): warning C4244: аргумент: преобразование "double" в "std::streamsize", возможна потеря данных +D:\StudioProject\Homework_STL\Homework_STL\Tasker.h(190,55): warning C4244: аргумент: преобразование "double" в "std::streamsize", возможна потеря данных +D:\StudioProject\Homework_STL\Homework_STL\Tasker.h(190,210): warning C4244: аргумент: преобразование "double" в "std::streamsize", возможна потеря данных +D:\StudioProject\Homework_STL\Homework_STL\Tasker.h(222,49): warning C4244: =: преобразование "double" в "int", возможна потеря данных +D:\StudioProject\Homework_STL\Homework_STL\Tasker.h(338,1): warning C4267: инициализация: преобразование из "size_t" в "int"; возможна потеря данных +D:\StudioProject\Homework_STL\Homework_STL\Tasker.h(355,1): warning C4267: инициализация: преобразование из "size_t" в "int"; возможна потеря данных +D:\StudioProject\Homework_STL\Homework_STL\Tasker.h(537,1): warning C4267: инициализация: преобразование из "size_t" в "int"; возможна потеря данных +D:\StudioProject\Homework_STL\Homework_STL\Main_STL.cpp(5,12): warning C4244: аргумент: преобразование "time_t" в "unsigned int", возможна потеря данных +D:\StudioProject\Homework_STL\Homework_STL\Menu.h(66): warning C4715: operator--: значение возвращается не при всех путях выполнения +D:\StudioProject\Homework_STL\Homework_STL\Menu.h(58): warning C4715: operator++: значение возвращается не при всех путях выполнения + Homework_STL.vcxproj -> D:\StudioProject\Homework_STL\x64\Debug\Homework_STL.exe diff --git a/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/CL.command.1.tlog b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/CL.command.1.tlog new file mode 100644 index 0000000..9952fca Binary files /dev/null and b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/CL.command.1.tlog differ diff --git a/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/CL.read.1.tlog b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/CL.read.1.tlog new file mode 100644 index 0000000..f902242 Binary files /dev/null and b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/CL.read.1.tlog differ diff --git a/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/CL.write.1.tlog b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/CL.write.1.tlog new file mode 100644 index 0000000..02fc02f Binary files /dev/null and b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/CL.write.1.tlog differ diff --git a/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/Homework_STL.lastbuildstate b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/Homework_STL.lastbuildstate new file mode 100644 index 0000000..8848a50 --- /dev/null +++ b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/Homework_STL.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.32.31326:TargetPlatformVersion=10.0.19041.0: +Debug|x64|D:\StudioProject\Homework_STL\| diff --git a/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/link.command.1.tlog b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/link.command.1.tlog new file mode 100644 index 0000000..48a4bcd Binary files /dev/null and b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/link.command.1.tlog differ diff --git a/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/link.read.1.tlog b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/link.read.1.tlog new file mode 100644 index 0000000..db0bd68 Binary files /dev/null and b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/link.read.1.tlog differ diff --git a/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/link.write.1.tlog b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/link.write.1.tlog new file mode 100644 index 0000000..0eabd1b Binary files /dev/null and b/Homework_STL/Homework_STL/x64/Debug/Homework_STL.tlog/link.write.1.tlog differ diff --git a/Homework_STL/Homework_STL/x64/Debug/Main_STL.obj b/Homework_STL/Homework_STL/x64/Debug/Main_STL.obj new file mode 100644 index 0000000..f4909e2 Binary files /dev/null and b/Homework_STL/Homework_STL/x64/Debug/Main_STL.obj differ diff --git a/Homework_STL/Homework_STL/x64/Debug/main_stl.obj.enc b/Homework_STL/Homework_STL/x64/Debug/main_stl.obj.enc new file mode 100644 index 0000000..baa9766 Binary files /dev/null and b/Homework_STL/Homework_STL/x64/Debug/main_stl.obj.enc differ diff --git a/Homework_STL/Homework_STL/x64/Debug/vc143.idb b/Homework_STL/Homework_STL/x64/Debug/vc143.idb new file mode 100644 index 0000000..5436980 Binary files /dev/null and b/Homework_STL/Homework_STL/x64/Debug/vc143.idb differ diff --git a/Homework_STL/Homework_STL/x64/Debug/vc143.pdb b/Homework_STL/Homework_STL/x64/Debug/vc143.pdb new file mode 100644 index 0000000..c1a5dfa Binary files /dev/null and b/Homework_STL/Homework_STL/x64/Debug/vc143.pdb differ diff --git a/TestProject/TestProject/TestProject.vcxproj b/Homework_STL/Test/Test.vcxproj similarity index 86% rename from TestProject/TestProject/TestProject.vcxproj rename to Homework_STL/Test/Test.vcxproj index 47df7e0..6785238 100644 --- a/TestProject/TestProject/TestProject.vcxproj +++ b/Homework_STL/Test/Test.vcxproj @@ -21,34 +21,34 @@ 16.0 Win32Proj - {7abdca86-dfbf-420f-ab8a-4389755199e8} - TestProject + {96227a10-1bb1-407b-8cbc-64f24e24d0c3} + Test 10.0 Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode @@ -70,18 +70,6 @@ - - true - - - false - - - true - - - false - Level3 @@ -141,6 +129,13 @@ + + + + + + + diff --git a/Homework_STL/Test/Test.vcxproj.filters b/Homework_STL/Test/Test.vcxproj.filters new file mode 100644 index 0000000..b5670ec --- /dev/null +++ b/Homework_STL/Test/Test.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + \ No newline at end of file diff --git a/Homework_STL/Test/Test.vcxproj.user b/Homework_STL/Test/Test.vcxproj.user new file mode 100644 index 0000000..0f14913 --- /dev/null +++ b/Homework_STL/Test/Test.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Homework_STL/Test/x64/Debug/Test.log b/Homework_STL/Test/x64/Debug/Test.log new file mode 100644 index 0000000..0b2af01 --- /dev/null +++ b/Homework_STL/Test/x64/Debug/Test.log @@ -0,0 +1,111 @@ + Source.cpp +D:\StudioProject\Homework_STL\Test\phrases.h(50,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(9,22): error C2039: "placeholders": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(9,34): error C2871: placeholders: пространство имен с таким именем не существует +D:\StudioProject\Homework_STL\Test\functions.h(11,18): error C2039: "function": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(11,26): error C2065: function: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(11,32): error C2144: синтаксическая ошибка: перед "int" требуется ")" +D:\StudioProject\Homework_STL\Test\functions.h(11,32): error C2062: тип "int" не требуется +D:\StudioProject\Homework_STL\Test\functions.h(11,36): error C2947: требуется ">" для завершения список аргументов шаблона, обнаружено ">>" +D:\StudioProject\Homework_STL\Test\functions.h(11,36): error C2059: синтаксическая ошибка: > +D:\StudioProject\Homework_STL\Test\functions.h(15,26): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(17,29): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(20,44): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(20,61): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(20,32): error C3861: max_element: идентификатор не найден +D:\StudioProject\Homework_STL\Test\functions.h(21,44): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(21,61): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(21,32): error C3861: min_element: идентификатор не найден +D:\StudioProject\Homework_STL\Test\functions.h(24,28): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(24,45): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(24,23): error C2672: "std::sort": не найдена соответствующая перегруженная функция +D:\StudioProject\Homework_STL\Test\functions.h(24,58): error C2780: void std::sort(const _RanIt,const _RanIt): требует аргументов: 2, имеется: 1 +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\algorithm(7463): message : см. объявление "std::sort" +D:\StudioProject\Homework_STL\Test\functions.h(24,58): error C2780: void std::sort(const _RanIt,const _RanIt,_Pr): требует аргументов: 3, имеется: 1 +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\algorithm(7455): message : см. объявление "std::sort" +D:\StudioProject\Homework_STL\Test\functions.h(24,69): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(28,2): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(28,17): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(29,10): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(32,30): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(32,48): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(34,36): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(36,45): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(36,63): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(38,38): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(38,55): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(38,23): error C2672: "std::random_shuffle": не найдена соответствующая перегруженная функция +D:\StudioProject\Homework_STL\Test\functions.h(38,68): error C2780: void std::random_shuffle(_RanIt,_RanIt): требует аргументов: 2, имеется: 1 +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\algorithm(4997): message : см. объявление "std::random_shuffle" +D:\StudioProject\Homework_STL\Test\functions.h(38,68): error C2780: void std::random_shuffle(_RanIt,_RanIt,_RngFn &&): требует аргументов: 3, имеется: 1 +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\algorithm(4975): message : см. объявление "std::random_shuffle" +D:\StudioProject\Homework_STL\Test\functions.h(38,79): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(40,46): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(40,64): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(42,30): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(44,19): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(44,46): error C2065: mainvec: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(48,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(48,30): error C2039: "bind": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(48,42): error C2660: bind: функция не принимает 1 аргументов +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winsock.h(744,16): message : см. объявление "bind" +D:\StudioProject\Homework_STL\Test\functions.h(49,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(49,30): error C2039: "bind": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(49,42): error C2660: bind: функция не принимает 1 аргументов +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winsock.h(744,16): message : см. объявление "bind" +D:\StudioProject\Homework_STL\Test\functions.h(50,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(50,30): error C2039: "bind": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(50,42): error C2660: bind: функция не принимает 1 аргументов +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winsock.h(744,16): message : см. объявление "bind" +D:\StudioProject\Homework_STL\Test\functions.h(51,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(51,30): error C2039: "bind": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(51,42): error C2660: bind: функция не принимает 1 аргументов +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winsock.h(744,16): message : см. объявление "bind" +D:\StudioProject\Homework_STL\Test\functions.h(52,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(52,30): error C2039: "bind": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(52,42): error C2660: bind: функция не принимает 1 аргументов +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winsock.h(744,16): message : см. объявление "bind" +D:\StudioProject\Homework_STL\Test\functions.h(53,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(53,30): error C2039: "bind": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(53,42): error C2660: bind: функция не принимает 1 аргументов +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winsock.h(744,16): message : см. объявление "bind" +D:\StudioProject\Homework_STL\Test\functions.h(54,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(54,30): error C2039: "bind": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(54,42): error C2660: bind: функция не принимает 1 аргументов +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winsock.h(744,16): message : см. объявление "bind" +D:\StudioProject\Homework_STL\Test\functions.h(55,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(55,30): error C2039: "bind": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(55,42): error C2660: bind: функция не принимает 1 аргументов +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winsock.h(744,16): message : см. объявление "bind" +D:\StudioProject\Homework_STL\Test\functions.h(56,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(56,30): error C2039: "bind": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(56,42): error C2660: bind: функция не принимает 1 аргументов +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winsock.h(744,16): message : см. объявление "bind" +D:\StudioProject\Homework_STL\Test\functions.h(57,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(57,30): error C2039: "bind": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(57,43): error C2660: bind: функция не принимает 1 аргументов +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winsock.h(744,16): message : см. объявление "bind" +D:\StudioProject\Homework_STL\Test\functions.h(58,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(58,30): error C2039: "bind": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(58,43): error C2660: bind: функция не принимает 1 аргументов +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winsock.h(744,16): message : см. объявление "bind" +D:\StudioProject\Homework_STL\Test\functions.h(59,2): error C2065: functions: необъявленный идентификатор +D:\StudioProject\Homework_STL\Test\functions.h(59,30): error C2039: "bind": не является членом "std". +D:\VisualStudio\VC\Tools\MSVC\14.32.31326\include\iostream(19): message : см. объявление "std" +D:\StudioProject\Homework_STL\Test\functions.h(59,43): error C2660: bind: функция не принимает 1 аргументов +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winsock.h(744,16): message : см. объявление "bind" +D:\StudioProject\Homework_STL\Test\Source.cpp(23,12): warning C4244: аргумент: преобразование "time_t" в "unsigned int", возможна потеря данных +D:\StudioProject\Homework_STL\Test\Source.cpp(24,2): error C2065: functions: необъявленный идентификатор diff --git a/Homework_STL/Test/x64/Debug/Test.tlog/CL.command.1.tlog b/Homework_STL/Test/x64/Debug/Test.tlog/CL.command.1.tlog new file mode 100644 index 0000000..46b134b --- /dev/null +++ b/Homework_STL/Test/x64/Debug/Test.tlog/CL.command.1.tlog @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Homework_STL/Test/x64/Debug/Test.tlog/Test.lastbuildstate b/Homework_STL/Test/x64/Debug/Test.tlog/Test.lastbuildstate new file mode 100644 index 0000000..8848a50 --- /dev/null +++ b/Homework_STL/Test/x64/Debug/Test.tlog/Test.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.32.31326:TargetPlatformVersion=10.0.19041.0: +Debug|x64|D:\StudioProject\Homework_STL\| diff --git a/Homework_STL/Test/x64/Debug/Test.tlog/unsuccessfulbuild b/Homework_STL/Test/x64/Debug/Test.tlog/unsuccessfulbuild new file mode 100644 index 0000000..e69de29 diff --git a/Homework_STL/Test/x64/Debug/vc143.idb b/Homework_STL/Test/x64/Debug/vc143.idb new file mode 100644 index 0000000..82ad23e Binary files /dev/null and b/Homework_STL/Test/x64/Debug/vc143.idb differ diff --git a/Homework_STL/Test/x64/Debug/vc143.pdb b/Homework_STL/Test/x64/Debug/vc143.pdb new file mode 100644 index 0000000..c57b828 Binary files /dev/null and b/Homework_STL/Test/x64/Debug/vc143.pdb differ diff --git a/Homework_STL/x64/Debug/Homework_STL.exe b/Homework_STL/x64/Debug/Homework_STL.exe new file mode 100644 index 0000000..a023955 Binary files /dev/null and b/Homework_STL/x64/Debug/Homework_STL.exe differ diff --git a/Homework_STL/x64/Debug/Homework_STL.pdb b/Homework_STL/x64/Debug/Homework_STL.pdb new file mode 100644 index 0000000..da0482a Binary files /dev/null and b/Homework_STL/x64/Debug/Homework_STL.pdb differ diff --git a/MatrixVector/MatrixVector.sln b/MatrixVector/MatrixVector.sln new file mode 100644 index 0000000..4d0f73b --- /dev/null +++ b/MatrixVector/MatrixVector.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32630.192 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MatrixVector", "MatrixVector\MatrixVector.vcxproj", "{6D8CD20E-5A01-4286-97CB-C5F82AFE9925}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6D8CD20E-5A01-4286-97CB-C5F82AFE9925}.Debug|x64.ActiveCfg = Debug|x64 + {6D8CD20E-5A01-4286-97CB-C5F82AFE9925}.Debug|x64.Build.0 = Debug|x64 + {6D8CD20E-5A01-4286-97CB-C5F82AFE9925}.Debug|x86.ActiveCfg = Debug|Win32 + {6D8CD20E-5A01-4286-97CB-C5F82AFE9925}.Debug|x86.Build.0 = Debug|Win32 + {6D8CD20E-5A01-4286-97CB-C5F82AFE9925}.Release|x64.ActiveCfg = Release|x64 + {6D8CD20E-5A01-4286-97CB-C5F82AFE9925}.Release|x64.Build.0 = Release|x64 + {6D8CD20E-5A01-4286-97CB-C5F82AFE9925}.Release|x86.ActiveCfg = Release|Win32 + {6D8CD20E-5A01-4286-97CB-C5F82AFE9925}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C4E62BDA-1003-45A7-A952-89D885608AE0} + EndGlobalSection +EndGlobal diff --git a/MatrixVector/MatrixVector/Color.h b/MatrixVector/MatrixVector/Color.h new file mode 100644 index 0000000..b724788 --- /dev/null +++ b/MatrixVector/MatrixVector/Color.h @@ -0,0 +1,43 @@ +#pragma once + +enum colors { + white, + yellow, + azure, + red, + blue, + violet, + green, + violet_dark, + blue_dark, + gray_dark, +}; + +class color { +private: + colors type; + +public: + color() : type(colors::white) {}; + color(colors _type) : type(_type) {}; + friend std::ostream& operator << (std::ostream& os, const color& color) { + HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); + color.type == white ? SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE) : + color.type == yellow ? SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY) : + color.type == azure ? SetConsoleTextAttribute(hStdout, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY) : + color.type == red ? SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_INTENSITY) : + color.type == blue ? SetConsoleTextAttribute(hStdout, FOREGROUND_BLUE | FOREGROUND_INTENSITY) : + color.type == violet ? SetConsoleTextAttribute(hStdout, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE) : + color.type == green ? SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN | FOREGROUND_INTENSITY) : + color.type == violet_dark ? SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_INTENSITY | FOREGROUND_BLUE) : + color.type == blue_dark ? SetConsoleTextAttribute(hStdout, FOREGROUND_BLUE | FOREGROUND_GREEN) : + color.type == gray_dark ? SetConsoleTextAttribute(hStdout, FOREGROUND_INTENSITY) : + NULL; + return os; + } + + std::string print(std::string word) { + std::cout << color(type) << word << color(); + return ""; + } +}; \ No newline at end of file diff --git a/MatrixVector/MatrixVector/Main.cpp b/MatrixVector/MatrixVector/Main.cpp new file mode 100644 index 0000000..601d609 --- /dev/null +++ b/MatrixVector/MatrixVector/Main.cpp @@ -0,0 +1,265 @@ +#include "Menu.h" + +bool chech_path(std::vector anspath, std::vector path); +void printMTRX(std::vector> matrix); +void MatrixMul(std::vector>& A, std::vector>& B); +void transpose(std::vector>& matrix); + +int main() { + srand(time(NULL)); + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + std::vector>> mainvec; + mainvec.push_back(std::vector>(1, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 })); + Answer answer; + Menu menu = Menu( + Board( + { + Button(TYPE::common_choose, " ()", {" ", " "}, Board( + { + Button(TYPE::common_choose, " ", {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, Board()) + } + )), + Button(TYPE::common, " ", {}, Board()), + Button(TYPE::common, " ", {}, Board()), + Button(TYPE::common, " ", {}, Board()), + Button(TYPE::common_choose, " ", {" ", " "}, Board()), + Button(TYPE::common, " ", {}, Board()), + Button(TYPE::common_end, "Exit from program", {}, Board()) + } + )); + menu.Blinking(FALSE); + menu.change_clear_method(CLEAR::_auto); + Menu menucopy = menu; + menucopy.Blinking(FALSE); + menucopy.change_clear_method(CLEAR::_auto); + while (true) { + answer = menu.enable(); + system("cls"); + int tmp_choose = answer.horizontal + 1; + if (!(answer.button_path.empty()) && answer.button_path[0] == "0") { + menu.reset_key(); + answer = menu.enable();; + } + + if (answer.iKey == static_cast(keyboard::KEY_EXIT) || answer.type == TYPE::common_end) { + system("cls"); + std::cout << color(red).print("Exit program!"); + _getch(); + break; + } + + else if (chech_path(answer.button_path, { "0", "0" })) { + int sizeMatrix = answer.horizontal + 1; + std::vector> matrix(sizeMatrix, std::vector(sizeMatrix)); + + if (tmp_choose == 2) { + // + for (int i = 0; i < sizeMatrix; i++) { + for (int j = 0; j < i; j++) { + matrix[i][j] = rand() % 10; + } + } + } + else if (tmp_choose == 1) { + // + for (int i = 0; i < sizeMatrix; i++) { + for (int j = i; j < sizeMatrix; j++) { + matrix[i][j] = rand() % 10; + } + } + } + + mainvec.push_back(matrix); + + printMTRX(matrix); + _getch(); + system("cls"); + menu = menucopy; + } + + else if (chech_path(answer.button_path, {"1"})) { + int size = mainvec.size(); + system("cls"); + for (int i = 0; i < size; i++) { + std::cout << color(yellow) << "=============================== " << color(azure) << "Matrix[" << i << "]" << color(yellow) << " ===============================\n"; + printMTRX(mainvec[i]); + } + _getch(); + system("cls"); + } + + else if (chech_path(answer.button_path, { "2" })) { + system("cls"); + Answer a; + std::vector strs; + int sizem = mainvec.size(); + for (int i = 0; i < sizem; i++) { strs.push_back(int_to_str(i + 1)); } + Menu m(Board( + { + Button(TYPE::common_choose, " ", strs, Board( + { + Button(TYPE::common_choose, " ", strs, Board()) + } + )) + } + )); + m.Blinking(FALSE); + m.change_clear_method(CLEAR::buffer_fill_void_100); + a = m.enable(); + system("cls"); + int tmpa = a.horizontal; + 1; + if (!(a.button_path.empty()) && a.button_path[0] == "0") { + m.reset_key(); + a = m.enable(); + } + if (mainvec[tmpa].size() >= mainvec[a.horizontal].size()) { + for (int i = 0; i < mainvec[tmpa].size(); i++) { + for (int g = 0; g < mainvec[tmpa].size(); g++) { + mainvec[tmpa][i][g] += mainvec[a.horizontal][i][g]; + } + } + } + else if (mainvec[tmpa].size() <= mainvec[a.horizontal].size()) { + for (int i = 0; i < mainvec[a.horizontal].size(); i++) { + for (int g = 0; g < mainvec[a.horizontal].size(); g++) { + mainvec[tmpa][i][g] += mainvec[a.horizontal][i][g]; + } + } + } + } + + else if (chech_path(answer.button_path, { "3" })) { + system("cls"); + Answer a; + std::vector strs; + int sizem = mainvec.size(); + for (int i = 0; i < sizem; i++) { strs.push_back(int_to_str(i + 1)); } + Menu m(Board( + { + Button(TYPE::common_choose, " ", strs, Board( + { + Button(TYPE::common_choose, " ", strs, Board()) + } + )) + } + )); + m.Blinking(FALSE); + m.change_clear_method(CLEAR::buffer_fill_void_100); + a = m.enable(); + system("cls"); + int tmpa = a.horizontal; +1; + if (!(a.button_path.empty()) && a.button_path[0] == "0") { + m.reset_key(); + a = m.enable(); + } + if (mainvec[tmpa].size() >= mainvec[a.horizontal].size()) { + for (int i = 0; i < mainvec[tmpa].size(); i++) { + for (int g = 0; g < mainvec[tmpa].size(); g++) { + mainvec[tmpa][i][g] -= mainvec[a.horizontal][i][g]; + } + } + } + else if (mainvec[tmpa].size() <= mainvec[a.horizontal].size()) { + for (int i = 0; i < mainvec[a.horizontal].size(); i++) { + for (int g = 0; g < mainvec[a.horizontal].size(); g++) { + mainvec[tmpa][i][g] -= mainvec[a.horizontal][i][g]; + } + } + } + } + + else if (chech_path(answer.button_path, { "4" })) { + system("cls"); + Answer a; + std::vector strs; + int sizem = mainvec.size(); + for (int i = 0; i < sizem; i++) { strs.push_back(int_to_str(i + 1)); } + Menu m(Board( + { + Button(TYPE::common_choose, " ", strs, Board( + { + Button(TYPE::common_choose, " ( 1)", strs, Board()) + } + )) + } + )); + m.Blinking(FALSE); + m.change_clear_method(CLEAR::buffer_fill_void_100); + a = m.enable(); + system("cls"); + int tmpa = a.horizontal; +1; + if (!(a.button_path.empty()) && a.button_path[0] == "0") { + m.reset_key(); + a = m.enable(); + } + if (mainvec[tmpa].size() == mainvec[a.horizontal].size()) { + MatrixMul(mainvec[tmpa], mainvec[a.horizontal]); + } + else if (mainvec[tmpa].size() == 1 || mainvec[a.horizontal].size() == 1) { + MatrixMul(mainvec[tmpa], mainvec[0]); + } + } + + else if (chech_path(answer.button_path, { "5" })) { + system("cls"); + Answer a; + std::vector strs; + int sizem = mainvec.size(); + for (int i = 0; i < sizem; i++) { strs.push_back(int_to_str(i + 1)); } + Menu m(Board( + { + Button(TYPE::common_choose, " ", strs, Board()) + } + )); + m.Blinking(FALSE); + m.change_clear_method(CLEAR::buffer_fill_void_100); + a = m.enable(); + transpose(mainvec[a.horizontal]); + } + } + return 0; +} + +bool chech_path(std::vector anspath, std::vector path) { + return anspath == std::vector(path); +} + +void printMTRX(std::vector> matrix) { + // + if (!(matrix.empty())) { + int x = matrix.size(); + int y = matrix[0].size(); + for (int i = 0; i < x; i++) { + for (int j = 0; j < y; j++) { + std::cout << matrix[i][j] << "\t"; + } + std::cout << "\n" << std::endl; + } + } +} + +void MatrixMul(std::vector>& A, std::vector>& B) { + int size = A.size(); + std::vector> C(size, std::vector(size)); + for (int i = 0; i < size; i++) { + for (int j = 0; j < size; j++) { + C[i][j] = 0; + for (int k = 0; k < size; k++) + C[i][j] += A[i][k] * B[k][j]; + } + } + A = C; +} + +void transpose(std::vector>& matrix) { + int size = matrix.size(); + int tmp; + for (int i = 0; i < size; i++) { + for (int j = i; j < size; j++) { + tmp = matrix[i][j]; + matrix[i][j] = matrix[j][i]; + matrix[j][i] = tmp; + } + } +} \ No newline at end of file diff --git a/MatrixVector/MatrixVector/MatrixVector.vcxproj b/MatrixVector/MatrixVector/MatrixVector.vcxproj new file mode 100644 index 0000000..ab0c632 --- /dev/null +++ b/MatrixVector/MatrixVector/MatrixVector.vcxproj @@ -0,0 +1,139 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {6d8cd20e-5a01-4286-97cb-c5f82afe9925} + MatrixVector + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/TestProject/TestProject/TestProject.vcxproj.filters b/MatrixVector/MatrixVector/MatrixVector.vcxproj.filters similarity index 76% rename from TestProject/TestProject/TestProject.vcxproj.filters rename to MatrixVector/MatrixVector/MatrixVector.vcxproj.filters index 6b008e6..13fd25a 100644 --- a/TestProject/TestProject/TestProject.vcxproj.filters +++ b/MatrixVector/MatrixVector/MatrixVector.vcxproj.filters @@ -15,7 +15,15 @@ - + + Файлы заголовков + + + Файлы заголовков + + + + Исходные файлы diff --git a/MatrixVector/MatrixVector/MatrixVector.vcxproj.user b/MatrixVector/MatrixVector/MatrixVector.vcxproj.user new file mode 100644 index 0000000..0f14913 --- /dev/null +++ b/MatrixVector/MatrixVector/MatrixVector.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/MatrixVector/MatrixVector/Menu.h b/MatrixVector/MatrixVector/Menu.h new file mode 100644 index 0000000..b93c535 --- /dev/null +++ b/MatrixVector/MatrixVector/Menu.h @@ -0,0 +1,454 @@ +#pragma once +#include +#include +#include +#include +#include + +unsigned int str_to_int(std::string _str); +std::string int_to_str(int _value); +void reverseSTR(std::string& str); + +#define SPACE_NAME 5 +#define SPACE_ARROW 1 +#define ANSI 48 +#define LEN_INPUT_NUMBER 6 + +#include "Color.h" + +class Menu; +class Board; +class Button; + +enum class CLEAR { + cls, + buffer_fill_void_100, + _auto, +}; + +enum class TYPE { + common, + common_choose, + common_value, + custom, + common_end, + common_choose_end, + common_value_end, + custom_end +}; + +enum class keyboard { + KEY_EXIT = 27, + KEY_ENTER = 13, + ARROW_KEY = 224, + KEY_SPACE = 32, + KEY_BACKSPACE = 8, + + KEY_ARROW_RIGHT = 77, + KEY_ARROW_LEFT = 75, + KEY_ARROW_UP = 72, + KEY_ARROW_DOWN = 80, + + KEY_0 = 0x30, + KEY_1 = 0x31, + KEY_2 = 0x32, + KEY_3 = 0x33, + KEY_4 = 0x34, + KEY_5 = 0x35, + KEY_6 = 0x36, + KEY_7 = 0x37, + KEY_8 = 0x38, + KEY_9 = 0x39, + + KEY_MINUS = 45, +}; + +struct Answer { + HANDLE hStdOut; + COORD cursorPos, startPos; + TYPE type; + int iKey, horizontal, vertical; + std::vector button_path; +}; + + +class Board { + friend class Menu; + friend class Button; +private: + std::vector