diff --git a/HW/HW_2/.vs/HW_2/v16/.suo b/HW/HW_2/.vs/HW_2/v16/.suo new file mode 100644 index 00000000..4ee75027 Binary files /dev/null and b/HW/HW_2/.vs/HW_2/v16/.suo differ diff --git a/HW/HW_2/.vs/HW_2/v16/Browse.VC.db b/HW/HW_2/.vs/HW_2/v16/Browse.VC.db new file mode 100644 index 00000000..feaa4919 Binary files /dev/null and b/HW/HW_2/.vs/HW_2/v16/Browse.VC.db differ diff --git a/HW/HW_2/.vs/HW_2/v16/Solution.VC.db b/HW/HW_2/.vs/HW_2/v16/Solution.VC.db new file mode 100644 index 00000000..3d8347be Binary files /dev/null and b/HW/HW_2/.vs/HW_2/v16/Solution.VC.db differ diff --git a/HW/HW_2/.vs/HW_2/v16/ipch/AutoPCH/37707d6cf175a9a7/MAIN.ipch b/HW/HW_2/.vs/HW_2/v16/ipch/AutoPCH/37707d6cf175a9a7/MAIN.ipch new file mode 100644 index 00000000..e3df899e Binary files /dev/null and b/HW/HW_2/.vs/HW_2/v16/ipch/AutoPCH/37707d6cf175a9a7/MAIN.ipch differ diff --git a/HW/HW_2/.vs/HW_2/v16/ipch/AutoPCH/38b1f42be0707973/MATRIX.ipch b/HW/HW_2/.vs/HW_2/v16/ipch/AutoPCH/38b1f42be0707973/MATRIX.ipch new file mode 100644 index 00000000..c6468959 Binary files /dev/null and b/HW/HW_2/.vs/HW_2/v16/ipch/AutoPCH/38b1f42be0707973/MATRIX.ipch differ diff --git a/HW/HW_2/.vs/HW_2/v16/ipch/AutoPCH/6219805972f36d13/MENU.ipch b/HW/HW_2/.vs/HW_2/v16/ipch/AutoPCH/6219805972f36d13/MENU.ipch new file mode 100644 index 00000000..2bb2c026 Binary files /dev/null and b/HW/HW_2/.vs/HW_2/v16/ipch/AutoPCH/6219805972f36d13/MENU.ipch differ diff --git a/HW/HW_2/HW1_Temp/HW1_Temp.vcxproj b/HW/HW_2/HW1_Temp/HW1_Temp.vcxproj new file mode 100644 index 00000000..51919ef9 --- /dev/null +++ b/HW/HW_2/HW1_Temp/HW1_Temp.vcxproj @@ -0,0 +1,151 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + 16.0 + Win32Proj + {7f9042c8-8758-4077-b86f-1977b636634d} + HW1Temp + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp20 + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpplatest + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/HW/HW_2/HW1_Temp/HW1_Temp.vcxproj.filters b/HW/HW_2/HW1_Temp/HW1_Temp.vcxproj.filters new file mode 100644 index 00000000..2ee5577f --- /dev/null +++ b/HW/HW_2/HW1_Temp/HW1_Temp.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {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/HW/HW_2/HW1_Temp/HW1_Temp.vcxproj.user b/HW/HW_2/HW1_Temp/HW1_Temp.vcxproj.user new file mode 100644 index 00000000..88a55094 --- /dev/null +++ b/HW/HW_2/HW1_Temp/HW1_Temp.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/HW/HW_2/HW1_Temp/TPoint.ixx b/HW/HW_2/HW1_Temp/TPoint.ixx new file mode 100644 index 00000000..96d8be68 --- /dev/null +++ b/HW/HW_2/HW1_Temp/TPoint.ixx @@ -0,0 +1,12 @@ +export module TPoint; + +export template +class TPoint +{ +private: + T x, y; + TPoint() { x = 0; y = 0 } + TPoint(T _x, T _y) { x = _x; y = _y }; + TPoint(const T& _Point) { x = _Point.x; y = _Point.y; return *this }; + +}; diff --git a/HW/HW_2/HW1_Temp/main.cpp b/HW/HW_2/HW1_Temp/main.cpp new file mode 100644 index 00000000..193fb8c1 --- /dev/null +++ b/HW/HW_2/HW1_Temp/main.cpp @@ -0,0 +1,2 @@ +import std.core; + diff --git a/HW/HW_2/HW_2.sln b/HW/HW_2/HW_2.sln new file mode 100644 index 00000000..eaa6dcff --- /dev/null +++ b/HW/HW_2/HW_2.sln @@ -0,0 +1,41 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32901.82 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HW1_Temp", "HW1_Temp\HW1_Temp.vcxproj", "{7F9042C8-8758-4077-B86F-1977B636634D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Matrix", "Matrix\Matrix.vcxproj", "{914C6D54-C8F1-48CA-AEC5-1ADBEEC1F2CB}" +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 + {7F9042C8-8758-4077-B86F-1977B636634D}.Debug|x64.ActiveCfg = Debug|x64 + {7F9042C8-8758-4077-B86F-1977B636634D}.Debug|x64.Build.0 = Debug|x64 + {7F9042C8-8758-4077-B86F-1977B636634D}.Debug|x86.ActiveCfg = Debug|Win32 + {7F9042C8-8758-4077-B86F-1977B636634D}.Debug|x86.Build.0 = Debug|Win32 + {7F9042C8-8758-4077-B86F-1977B636634D}.Release|x64.ActiveCfg = Release|x64 + {7F9042C8-8758-4077-B86F-1977B636634D}.Release|x64.Build.0 = Release|x64 + {7F9042C8-8758-4077-B86F-1977B636634D}.Release|x86.ActiveCfg = Release|Win32 + {7F9042C8-8758-4077-B86F-1977B636634D}.Release|x86.Build.0 = Release|Win32 + {914C6D54-C8F1-48CA-AEC5-1ADBEEC1F2CB}.Debug|x64.ActiveCfg = Debug|x64 + {914C6D54-C8F1-48CA-AEC5-1ADBEEC1F2CB}.Debug|x64.Build.0 = Debug|x64 + {914C6D54-C8F1-48CA-AEC5-1ADBEEC1F2CB}.Debug|x86.ActiveCfg = Debug|Win32 + {914C6D54-C8F1-48CA-AEC5-1ADBEEC1F2CB}.Debug|x86.Build.0 = Debug|Win32 + {914C6D54-C8F1-48CA-AEC5-1ADBEEC1F2CB}.Release|x64.ActiveCfg = Release|x64 + {914C6D54-C8F1-48CA-AEC5-1ADBEEC1F2CB}.Release|x64.Build.0 = Release|x64 + {914C6D54-C8F1-48CA-AEC5-1ADBEEC1F2CB}.Release|x86.ActiveCfg = Release|Win32 + {914C6D54-C8F1-48CA-AEC5-1ADBEEC1F2CB}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3BD04694-25CE-44A3-B1C9-8E87CDDBB307} + EndGlobalSection +EndGlobal diff --git a/HW/HW_2/Matrix/Matrix.vcxproj b/HW/HW_2/Matrix/Matrix.vcxproj new file mode 100644 index 00000000..88656f65 --- /dev/null +++ b/HW/HW_2/Matrix/Matrix.vcxproj @@ -0,0 +1,149 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {914c6d54-c8f1-48ca-aec5-1adbeec1f2cb} + Matrix + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + 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 + stdcpplatest + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/HW/HW_2/Matrix/Matrix.vcxproj.filters b/HW/HW_2/Matrix/Matrix.vcxproj.filters new file mode 100644 index 00000000..e8deb3dc --- /dev/null +++ b/HW/HW_2/Matrix/Matrix.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {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/HW/HW_2/Matrix/Matrix.vcxproj.user b/HW/HW_2/Matrix/Matrix.vcxproj.user new file mode 100644 index 00000000..88a55094 --- /dev/null +++ b/HW/HW_2/Matrix/Matrix.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/HW/HW_2/Matrix/main.cpp b/HW/HW_2/Matrix/main.cpp new file mode 100644 index 00000000..3d2d3cb6 --- /dev/null +++ b/HW/HW_2/Matrix/main.cpp @@ -0,0 +1,429 @@ +#include +#include +#include +using namespace std; + +vector>, int>>> MyMatrices; + +void showMenu() +{ + system("cls"); + cout << "\tTriangle Matrix Menu" << endl << endl; + cout << "1 - Show my matrices" << endl; + cout << "2 - Create matrix" << endl; + cout << "3 - Sum matrces" << endl; + cout << "4 - Subtract matrices" << endl; + cout << "5 - Multyply by matrix" << endl; + cout << "6 - Multyply by vector" << endl; + cout << "7 - Transpose matrix" << endl; + cout << "8 - Delete Matrix" << endl; + cout << "0 - Exit" << endl; + cout << "Insert number from menu: "; +} + +void printMatrix(vector> _matrix) +{ + for (int i = 0; i != _matrix.size(); i++) + { + for (int j = 0; j != _matrix[i].size(); j++) + cout << _matrix[i][j] << "\t"; + cout << endl; + } +} + +void showMyMatrices() +{ + if (MyMatrices.empty()) + cout << "You don't have any" << endl; + else + { + for (int i = 0; i != MyMatrices.size(); i++) + { + cout << MyMatrices[i].first << endl; + printMatrix(MyMatrices[i].second.first); + } + } +} + +void createMatrix() +{ + system ("cls"); + pair>, unsigned int>> matrix; + int degree, lu; + cout << "Your's Matrix name: "; + cin >> matrix.first; + cout << endl; + while (true) + { + cout << "Your Matrix is:\n1 - Lower\n2 - Upper" << endl; + string number; + cin >> number; + try + { + lu = stoi(number); + } + catch (exception& e) + { + lu = 0; + } + if (lu != 1 && lu != 2) + cout << "Incorect value, try again" << endl; + else + break; + } + while (true) + { + cout << "Your Matrix degree: "; + string number; + cin >> number; + try + { + degree = stoi(number); + } + catch (exception&) + { + degree = 0; + } + if (degree < 1) + cout << "Incorect value, try again" << endl; + else + break; + } + if (lu == 1) + { + for (int i = 0; i < degree; i++) + { + vector vec; + for (int j = 0; j <= i; j++) + { + int value; + while (true) + { + cout << "Insert value: "; + string _value; + bool exit = 1; + cin >> _value; + try + { + value = stoi(_value); + } + catch (const exception&) + { + cout << "Incorect value, try again" << endl; + exit = 0; + } + if (exit) + break; + } + vec.push_back(value); + } + cout << endl; + for (int v = degree - 1; v > i; v--) + vec.push_back(0); + matrix.second.first.push_back(vec); + } + } + else + { + for (int i = 0; i < degree; i++) + { + vector vec; + for (int j = degree; j > i; j--) + { + int value; + while (true) + { + cout << "Insert value: "; + string _value; + bool exit = 1; + cin >> _value; + try + { + value = stoi(_value); + } + catch (const exception&) + { + cout << "Incorect value, try again" << endl; + exit = 0; + } + if (exit) + break; + } + vec.push_back(value); + } + cout << endl; + for (int v = degree - i; v < degree; v++) + vec.insert(vec.begin(), 0); + matrix.second.first.push_back(vec); + } + } + matrix.second.second = degree; + MyMatrices.push_back(matrix); +} + +bool checkMatrices() +{ + int sameDeg = 0; + for (int i = 0; i < MyMatrices.size() - 1; i++) + for (int j = i + 1; j < MyMatrices.size(); j++) + if (MyMatrices[i].second.second - 1 == MyMatrices[j].second.second - 1) + { + sameDeg++; + break; + } + if (sameDeg > 0) + return 1; + else + return 0; +} + +int chooseMatrix() +{ + if (MyMatrices.size() < 1) + { + cout << "You need at least one matrix for this" << endl; + system("pause"); + } + else + cout << "Choose matrix" << endl; + for (int i = 0; i < MyMatrices.size(); i++) + cout << i + 1 << " " << MyMatrices[i].first << endl; + int mat; + while (true) + { + cout << "Matrix: "; + string _mat; + cin >> _mat; + try + { + mat = stoi(_mat); + } + catch (const exception&) + { + mat = 0; + } + mat--; + if (mat < 0 || mat > MyMatrices.size() - 1) + cout << "Incorect value, try again" << endl; + else + if (MyMatrices[mat].second.second < 0) + cout << "You cant choose vector" << endl; + else + return mat; + } + +} + +void sumMatrices() +{ + if (checkMatrices()) + { + int matFirst = chooseMatrix(); + int matSecond = chooseMatrix(); + vector> sumFSMat; + for (int i = 0; i < MyMatrices[matFirst].second.second; i++) + { + vector vec; + for (int j = 0; j < MyMatrices[matFirst].second.second; j++) + vec.push_back(MyMatrices[matFirst].second.first[i][j] + MyMatrices[matSecond].second.first[i][j]); + sumFSMat.push_back(vec); + } + pair>, int>> sumFS; + sumFS = { MyMatrices[matFirst].first + "+" + MyMatrices[matSecond].first, {sumFSMat, MyMatrices[matFirst].second.second} }; + MyMatrices.push_back(sumFS); + } + else + { + cout << "You need to create at least 2 matrices with same degree" << endl; + system("pause"); + } +} + +void substractMatrices() +{ + if (checkMatrices()) + { + int matFirst = chooseMatrix(); + int matSecond = chooseMatrix(); + vector> subFSMat; + for (int i = 0; i < MyMatrices[matFirst].second.second; i++) + { + vector vec; + for (int j = 0; j < MyMatrices[matFirst].second.second; j++) + vec.push_back(MyMatrices[matFirst].second.first[i][j] - MyMatrices[matSecond].second.first[i][j]); + subFSMat.push_back(vec); + } + pair>, int>> subFS; + subFS = { MyMatrices[matFirst].first + "-" + MyMatrices[matSecond].first, {subFSMat, MyMatrices[matFirst].second.second} }; + MyMatrices.push_back(subFS); + } + else + { + cout << "You need to create at least 2 matrices with same degree" << endl; + system("pause"); + } +} + +void multyplyMatrix() +{ + if (checkMatrices()) + { + int matFirst = chooseMatrix(); + int matSecond = chooseMatrix(); + vector> mulFSMat; + for (int i = 0; i < MyMatrices[matFirst].second.second; i++) + { + vector vec; + for (int j = 0; j < MyMatrices[matFirst].second.second; j++) + { + int value = 0; + for (int k = 0; k < MyMatrices[matFirst].second.second; k++) + value += MyMatrices[matFirst].second.first[i][k] * MyMatrices[matSecond].second.first[k][j]; + vec.push_back(value); + } + mulFSMat.push_back(vec); + } + pair>, int>> mulFS; + mulFS = { MyMatrices[matFirst].first + "*" + MyMatrices[matSecond].first, {mulFSMat, MyMatrices[matFirst].second.second} }; + MyMatrices.push_back(mulFS); + } + else + { + cout << "You need to create at least 2 matrices with same degree" << endl; + system("pause"); + } +} + +void multiplyMatByVec() +{ + int mat = chooseMatrix(); + vector vec; + string vecName; + cout << "Your vector name: "; + cin >> vecName; + for (int i = 0; i < MyMatrices[mat].second.second; i++) + { + int value; + while (true) + { + string _value; + bool exit = 1; + cout << "Insert value: "; + cin >> _value; + try + { + value = stoi(_value); + } + catch (const exception&) + { + cout << "Incorect value, try again" << endl; + exit = 0; + } + if (exit) + break; + } + } + for (int i = 0; i < MyMatrices[mat].second.second; i++) + { + int value = 0; + for (int j = 0; j < MyMatrices[mat].second.second; j++) + { + value += MyMatrices[mat].second.first[i][j] * vec[j]; + vec.push_back(value); + } + } + vector> _vec{ vec }; + MyMatrices.push_back({ MyMatrices[mat].first + "*" + vecName, {_vec , -MyMatrices[mat].second.second} }); +} + +void transposeMatrix() +{ + int mat = chooseMatrix(); + vector> matT; + for (int i = 0; i < MyMatrices[mat].second.second; i++) + { + vector vec; + for (int j = 0; j < MyMatrices[mat].second.second; j++) + vec.push_back(MyMatrices[mat].second.first[j][i]); + matT.push_back(vec); + } + pair>, int>> _matT = { "Transposed_" + MyMatrices[mat].first, {matT, MyMatrices[mat].second.second}}; + MyMatrices.push_back(_matT); +} + +void deleteMatrix() +{ + int mat = chooseMatrix(); + MyMatrices.erase(MyMatrices.begin() + mat); +} + +int main() +{ + int switch_on = 1; + while (switch_on != 0) + { + showMenu(); + cin >> switch_on; + switch (switch_on) + { + case 1: + { + system("cls"); + showMyMatrices(); + system("pause"); + break; + } + case 2: + { + createMatrix(); + break; + } + case 3: + { + sumMatrices(); + break; + } + case 4: + { + substractMatrices(); + break; + } + case 5: + { + multyplyMatrix(); + break; + } + case 6: + { + multiplyMatByVec(); + break; + } + case 7: + { + transposeMatrix(); + break; + } + case 8: + { + if (MyMatrices.size() == 0) + { + cout << "To do this, you need to create at least one matrix" << endl; + system("pause"); + } + else + deleteMatrix(); + break; + } + case 0: + { + break; + } + default: + { + cout << "Incorect value, try again" << endl; + system("pause"); + break; + } + } + } +} \ No newline at end of file