From 4bf1c9f0a26764d2911087ef6dfd4f491a04284a Mon Sep 17 00:00:00 2001 From: augeliua Date: Thu, 14 Nov 2024 08:53:17 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B2=D0=BE=D0=B5=20=D0=B8?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ОАиП_Lab_13/ОАиП_Lab_13.sln | 31 +++ ОАиП_Lab_13/ОАиП_Lab_13/Source.cpp | 241 ++++++++++++++++++ .../ОАиП_Lab_13/ОАиП_Lab_13.vcxproj | 135 ++++++++++ .../ОАиП_Lab_13.vcxproj.filters | 22 ++ 4 files changed, 429 insertions(+) create mode 100644 ОАиП_Lab_13/ОАиП_Lab_13.sln create mode 100644 ОАиП_Lab_13/ОАиП_Lab_13/Source.cpp create mode 100644 ОАиП_Lab_13/ОАиП_Lab_13/ОАиП_Lab_13.vcxproj create mode 100644 ОАиП_Lab_13/ОАиП_Lab_13/ОАиП_Lab_13.vcxproj.filters diff --git a/ОАиП_Lab_13/ОАиП_Lab_13.sln b/ОАиП_Lab_13/ОАиП_Lab_13.sln new file mode 100644 index 0000000..eacdd48 --- /dev/null +++ b/ОАиП_Lab_13/ОАиП_Lab_13.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35222.181 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ОАиП_Lab_13", "ОАиП_Lab_13\ОАиП_Lab_13.vcxproj", "{D056C1AE-BE45-43BA-A0C7-EAA6BF6863F8}" +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 + {D056C1AE-BE45-43BA-A0C7-EAA6BF6863F8}.Debug|x64.ActiveCfg = Debug|x64 + {D056C1AE-BE45-43BA-A0C7-EAA6BF6863F8}.Debug|x64.Build.0 = Debug|x64 + {D056C1AE-BE45-43BA-A0C7-EAA6BF6863F8}.Debug|x86.ActiveCfg = Debug|Win32 + {D056C1AE-BE45-43BA-A0C7-EAA6BF6863F8}.Debug|x86.Build.0 = Debug|Win32 + {D056C1AE-BE45-43BA-A0C7-EAA6BF6863F8}.Release|x64.ActiveCfg = Release|x64 + {D056C1AE-BE45-43BA-A0C7-EAA6BF6863F8}.Release|x64.Build.0 = Release|x64 + {D056C1AE-BE45-43BA-A0C7-EAA6BF6863F8}.Release|x86.ActiveCfg = Release|Win32 + {D056C1AE-BE45-43BA-A0C7-EAA6BF6863F8}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {315022A1-7B72-4393-9E37-BF404AB4DD7A} + EndGlobalSection +EndGlobal diff --git a/ОАиП_Lab_13/ОАиП_Lab_13/Source.cpp b/ОАиП_Lab_13/ОАиП_Lab_13/Source.cpp new file mode 100644 index 0000000..01b2acb --- /dev/null +++ b/ОАиП_Lab_13/ОАиП_Lab_13/Source.cpp @@ -0,0 +1,241 @@ +#include +#include + +#define NUM_ELEMENTS 10 + +int arr[NUM_ELEMENTS]; +int n = 0; + +void printElements() { + for (int i = 0; i < n; i++) { + printf("%d ", arr[i]); + } +} + +void keyboardInput() { + printf("n = "); + scanf_s("%d", &n); + + printf(" %d : ", n); + for (int i = 0; i < n; i++) { + scanf_s("%d", &arr[i]); + } +} + +void oddsX10() { + for (int i = 0; i < n; i++) { + if (arr[i] % 2 == 1) { + arr[i] = arr[i] * 10; + } + } +} + +int findMin() { + int min = arr[0]; + for (int i = 1; i < n; i++) { + if (arr[i] < min) { + min = arr[i]; + } + } + return min; +} + +int FindIndexMin() { + int min = arr[0]; + int index = 0; + for (int i = 1; i < n; i++) { + if (arr[i] < min) { + min = arr[i]; + index = i; + } + } + return index; +} + +int MoreThan10() { + int cnt = 0; + for (int i = 0; i < n; i++) { + + if (arr[i] > 10) { + cnt += 1; + } + } + return cnt; +} + +void TwiceLastEven() { + int index = 0; + for (int i = 0; i < n; i++) { + if (arr[i] % 2 == 0) { + index = i; + } + } + arr[index] = 2 * arr[index]; +} + +void HowManyLeft() { + int index = FindIndexMin(); + printf(" = %d \n", index); + + int cnt = 0; + for (int i = 0; i < index; i++) { + if (arr[i] % 2 == 0) { + cnt++; + } + } + printf(" %d \n", cnt); +} + +void MinusEven() { + for (int i = 0; i < n; i++) { + if (arr[i] % 2 == 0) { + arr[i] = -1 * arr[i]; + } + } +} + +void OnlyMore4() { + for (int i = 0; i < n; i++) { + if (arr[i] < 4) { + arr[i] = 4; + } + } +} + +void BetweenEven() { + for (int i = 1; i < (n - 1); i++) { + if ((arr[i - 1] % 2 == 0) && (arr[i + 1] % 2 == 0)) { + arr[i] = 1; + } + } +} + + +// 14 + +void DeleteElement(int index) { + for (int i = index; i < (n - 1); i++) { + arr[i] = arr[i + 1]; + } + n--; +} + +void InsertElement(int index, int value) { + for (int i = n; i > index; i--) { + arr[i] = arr[i - 1]; + } + n++; + arr[index] = value; +} + +void main() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + int item; + do { + printf("\n"); + printf("------------------------------\n"); + printf(" : "); + printElements(); + printf("\n"); + printf(" :\n"); + printf("1: \n"); + printf("2: x10 \n"); + printf("3: \n"); + printf("4: 10 \n"); + printf("5: 2 \n"); + printf("6: \n"); + printf("7: -1 \n"); + printf("8: , 4, 4 \n"); + printf("9: , , 1 \n"); + printf("10: \n"); + printf("11: \n"); + printf("12: \n"); + printf("13: 0 \n"); + printf("\n"); + printf("0: \n"); + printf(" >>>>>> "); + + scanf_s("%d", &item); + + switch (item) { + case 1: + keyboardInput(); + break; + + case 2: + oddsX10(); + break; + + case 3: + { + int min = findMin(); + printf("min = %d\n", min); + break; + } + + case 4: + { + int cnt = MoreThan10(); + printf("%d 10 \n", cnt); + break; + } + + case 5: + TwiceLastEven(); + break; + + case 6: + HowManyLeft(); + break; + + case 7: + MinusEven(); + break; + + case 8: + OnlyMore4(); + break; + case 9: + BetweenEven(); + break; + + // 14 + case 10: + { + printf(" : "); + int index; + scanf_s("%d", &index); + DeleteElement(index); + break; + } + case 11: + { + printf(" ? : "); + int index; + scanf_s("%d", &index); + + printf(", = "); + int value; + scanf_s("%d", &value); + + InsertElement(index, value); + break; + } + case 12: + { + int min = FindIndexMin(); + printf("min = %d", arr[min]); + DeleteElement(min); + break; + } + case 13: + { + int min = FindIndexMin(); + InsertElement(min, 0); + break; + } + } + + } while (item != 0); +} \ No newline at end of file diff --git a/ОАиП_Lab_13/ОАиП_Lab_13/ОАиП_Lab_13.vcxproj b/ОАиП_Lab_13/ОАиП_Lab_13/ОАиП_Lab_13.vcxproj new file mode 100644 index 0000000..b507731 --- /dev/null +++ b/ОАиП_Lab_13/ОАиП_Lab_13/ОАиП_Lab_13.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {d056c1ae-be45-43ba-a0c7-eaa6bf6863f8} + ОАиПLab13 + 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/ОАиП_Lab_13/ОАиП_Lab_13/ОАиП_Lab_13.vcxproj.filters b/ОАиП_Lab_13/ОАиП_Lab_13/ОАиП_Lab_13.vcxproj.filters new file mode 100644 index 0000000..ef66db6 --- /dev/null +++ b/ОАиП_Lab_13/ОАиП_Lab_13/ОАиП_Lab_13.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