From 7534739401929ada1ceb1017950dca48ede41f83 Mon Sep 17 00:00:00 2001 From: Dmitriy Gorshenin Date: Sat, 14 May 2022 15:46:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B0=D1=88=D0=B8=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BA=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Part1/Lab1/Mashinnoe/Lab1_1.sln | 31 ---- Part1/Lab1/Mashinnoe/Lab1_1.vcxproj | 150 ---------------- Part1/Lab1/Mashinnoe/Lab1_1.vcxproj.filters | 27 --- Part1/Lab1/Mashinnoe/Lab1_1.vcxproj.user | 4 - Part1/Lab1/Mashinnoe/zavtrak.cpp | 189 -------------------- 5 files changed, 401 deletions(-) delete mode 100644 Part1/Lab1/Mashinnoe/Lab1_1.sln delete mode 100644 Part1/Lab1/Mashinnoe/Lab1_1.vcxproj delete mode 100644 Part1/Lab1/Mashinnoe/Lab1_1.vcxproj.filters delete mode 100644 Part1/Lab1/Mashinnoe/Lab1_1.vcxproj.user delete mode 100644 Part1/Lab1/Mashinnoe/zavtrak.cpp diff --git a/Part1/Lab1/Mashinnoe/Lab1_1.sln b/Part1/Lab1/Mashinnoe/Lab1_1.sln deleted file mode 100644 index 3fb184a..0000000 --- a/Part1/Lab1/Mashinnoe/Lab1_1.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31025.194 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lab1_1", "Lab1_1.vcxproj", "{8E1DEADF-98BA-4947-9AED-5486C2F7B9F5}" -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 - {8E1DEADF-98BA-4947-9AED-5486C2F7B9F5}.Debug|x64.ActiveCfg = Debug|x64 - {8E1DEADF-98BA-4947-9AED-5486C2F7B9F5}.Debug|x64.Build.0 = Debug|x64 - {8E1DEADF-98BA-4947-9AED-5486C2F7B9F5}.Debug|x86.ActiveCfg = Debug|Win32 - {8E1DEADF-98BA-4947-9AED-5486C2F7B9F5}.Debug|x86.Build.0 = Debug|Win32 - {8E1DEADF-98BA-4947-9AED-5486C2F7B9F5}.Release|x64.ActiveCfg = Release|x64 - {8E1DEADF-98BA-4947-9AED-5486C2F7B9F5}.Release|x64.Build.0 = Release|x64 - {8E1DEADF-98BA-4947-9AED-5486C2F7B9F5}.Release|x86.ActiveCfg = Release|Win32 - {8E1DEADF-98BA-4947-9AED-5486C2F7B9F5}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {83E70304-D43D-4184-9D07-00854F397EB3} - EndGlobalSection -EndGlobal diff --git a/Part1/Lab1/Mashinnoe/Lab1_1.vcxproj b/Part1/Lab1/Mashinnoe/Lab1_1.vcxproj deleted file mode 100644 index d137fe3..0000000 --- a/Part1/Lab1/Mashinnoe/Lab1_1.vcxproj +++ /dev/null @@ -1,150 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {8e1deadf-98ba-4947-9aed-5486c2f7b9f5} - Lab11 - 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 - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - \ No newline at end of file diff --git a/Part1/Lab1/Mashinnoe/Lab1_1.vcxproj.filters b/Part1/Lab1/Mashinnoe/Lab1_1.vcxproj.filters deleted file mode 100644 index bbbed9d..0000000 --- a/Part1/Lab1/Mashinnoe/Lab1_1.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {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/Part1/Lab1/Mashinnoe/Lab1_1.vcxproj.user b/Part1/Lab1/Mashinnoe/Lab1_1.vcxproj.user deleted file mode 100644 index 0f14913..0000000 --- a/Part1/Lab1/Mashinnoe/Lab1_1.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Part1/Lab1/Mashinnoe/zavtrak.cpp b/Part1/Lab1/Mashinnoe/zavtrak.cpp deleted file mode 100644 index d956836..0000000 --- a/Part1/Lab1/Mashinnoe/zavtrak.cpp +++ /dev/null @@ -1,189 +0,0 @@ -#include -#include -#include -#include -#include -#include -using namespace std; - -const int length = 32; -const char universum[] = "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"; -char stringA[length]; -char stringB[length]; -char stringC[length]; -char stringD[length]; -bool vectorA[length], vectorB[length], vectorC[length], vectorD[length], vectorF[length]; -double firstTimePoint, lastTimePoint, totalTime = 0; -const char filename[] = "output.txt"; -const int testAmount = 10; - - - -void setupConsole() -{ - setlocale(LC_ALL, "Russian"); - SetConsoleOutputCP(1251); - SetConsoleCP(1251); -} - -void outputGreeting() -{ - cout << "Программа рассчитывает значение множества F согласно следующим законам - " << endl; - cout << "F = A - (B v C v D), что равносильно F = A - B - C - D." << endl; - cout << "Универсум: " << universum << endl; -} - -void input() -{ - cout << endl; - cout << "Введите множество A: "; - cin >> stringA; - cout << "Введите множество B: "; - cin >> stringB; - cout << "Введите множество C: "; - cin >> stringC; - cout << "Введите множество D: "; - cin >> stringD; - - cout << endl; -} - -int memberToIndex(char member) -{ - return member - 'А'; -} - -char indexToMember(int number) -{ - return number + 'А'; -} - -void vectorFromString(bool*vector, const char string[]) -{ - for (int i = 0; string[i]; i++) - vector[memberToIndex(string[i])] = 1; -}; - -void convertSets() -{ - vectorFromString(vectorA, stringA); - vectorFromString(vectorB, stringB); - vectorFromString(vectorC, stringC); - vectorFromString(vectorD, stringD); -} - -void calculateAnswer() -{ - for (int i = 0; i < length; i++) - vectorF[i] = (vectorA[i] && !vectorB[i] && !vectorC[i] && !vectorD[i]); -} - -void outputSetToConsole(bool(&vector)[length]) -{ - for (int i = 0; i < length; ++i) - if (vector[i]) - cout << indexToMember(i); -} - -void outputSetToFile(bool(&vector)[length], ofstream& output) -{ - for (int i = 0; i < length; ++i) - if (vector[i]) - output << indexToMember(i); -} - -void executeTask() -{ - convertSets(); - calculateAnswer(); -} - -void outputAnswer() -{ - cout << "Ответ: F = "; - outputSetToConsole(vectorF); - cout << endl; -} - -int factorial(int number) -{ - int factorial = 1; - for (int i = 1; i <= number; i++) - factorial *= number; - return factorial; -} - -bool randomBool() -{ - return rand() % 2; -} - -void fillVectors() -{ - for (int i = 0; i < length; i++) - { - vectorA[i] = randomBool(); - vectorB[i] = randomBool(); - vectorC[i] = randomBool(); - vectorD[i] = randomBool(); - } -} - -void clearAnswerVector() -{ - for (int i = 0; i < length; i++) - vectorF[i] = 0; -} - -void executeTest() -{ - ofstream output; - output.open(filename); - for (int i = 0; i < testAmount; i++) - { - fillVectors(); - clearAnswerVector(); - output << "Множество A: "; - outputSetToFile(vectorA, output); - output << endl; - output << "Множество B: "; - outputSetToFile(vectorB, output); - output << endl; - output << "Множество C: "; - outputSetToFile(vectorC, output); - output << endl; - output << "Множество D: "; - outputSetToFile(vectorD, output); - output << endl; - firstTimePoint = clock(); - calculateAnswer(); - lastTimePoint = clock(); - totalTime += lastTimePoint - firstTimePoint; - output << "Ответ: F = "; - outputSetToFile(vectorF, output); - output << endl; - output << '*' << endl; - } - output.close(); -} - -void outputTestInfo() -{ - cout << endl; - cout << "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" << endl; - cout << "Из 33 символов может быть составлено " << factorial(length) << " перестановок" << endl; - cout << "Программой будут рассмотрены лишь " << testAmount << " случайных комбинаций" << endl; - cout << "Отчеты будут выведены в файл output.txt" << endl; - cout << "На выполнение алгоритма уходит " << totalTime / 1000 << " секунд." << endl; -} - -int main() -{ - setupConsole(); - outputGreeting(); - input(); - executeTask(); - outputAnswer(); - executeTest(); - outputTestInfo(); -}