From 0a40f356b4b9fd0ace62d33fcb0fa3bdd7b65f03 Mon Sep 17 00:00:00 2001 From: aleksandrkirusin Date: Mon, 28 Oct 2024 15:29:32 +0400 Subject: [PATCH] commit1 --- Lab9-10_OAandP/Lab9-10_OAandP.cpp | 137 +++++++++ Lab9-10_OAandP/Lab9-10_OAandP.sln | 37 +++ Lab9-10_OAandP/Lab9-10_OAandP.vcxproj | 190 +++++++++++++ Lab9-10_OAandP/Lab9-10_OAandP.vcxproj.filters | 22 ++ Lab9-10_OAandP/main.cpp | 269 ++++++++++++++++++ 5 files changed, 655 insertions(+) create mode 100644 Lab9-10_OAandP/Lab9-10_OAandP.cpp create mode 100644 Lab9-10_OAandP/Lab9-10_OAandP.sln create mode 100644 Lab9-10_OAandP/Lab9-10_OAandP.vcxproj create mode 100644 Lab9-10_OAandP/Lab9-10_OAandP.vcxproj.filters create mode 100644 Lab9-10_OAandP/main.cpp diff --git a/Lab9-10_OAandP/Lab9-10_OAandP.cpp b/Lab9-10_OAandP/Lab9-10_OAandP.cpp new file mode 100644 index 0000000..a24fa98 --- /dev/null +++ b/Lab9-10_OAandP/Lab9-10_OAandP.cpp @@ -0,0 +1,137 @@ +#include +#include + +void print1_10(), print10_1(), print5Odds(), print100_10_while(), print1000_100_while(), print1000_0_while(), Task1(), Task2(); + +void main() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + int n; + do { + printf("\n"); + printf("\n"); + printf("Выберите нужную вам операцию:\n"); + printf("1: Вывести числа от 1 до 10\n"); + printf("2: Вывести числа от 10 до 1\n"); + printf("3: Вывести 5 первых нечетных чисел начиная с 1\n"); + printf("11: Вывести числа от 100 до 10 с шагом 10\n"); + printf("12: Вывести числа от 1000 до 100 с шагом 100\n"); + printf("20: Вывести числа от 1000 до 0 с шагом 16\n"); + printf("101: 10 ЛАБА - Задача 1\n"); + printf("102: 10 ЛАБА - Задача 2\n"); + printf("\n"); + printf("0: Выйти из программы\n"); + scanf_s("%d", &n); + switch (n) { + case 1: + print1_10(); + break; + case 2: + print10_1(); + break; + case 3: + print5Odds(); + break; + case 11: + print100_10_while(); + break; + case 12: + print1000_100_while(); + break; + case 20: + print1000_0_while(); + break; + case 101: + Task1(); + break; + case 102: + Task2(); + break; + } + } while (n != 0); +} + +void print1_10() { + int a = 1; + do { + printf("%d ", a); + a++; + } while (a <= 10); +} +void print10_1() { + int a = 10; + while (a >= 1) { + printf("%d ", a); + a--; + } +} +void print5Odds() { + int a = 1; + int i = 1; + while (i <= 5) { + printf("%d ", a); + a = a + 2; + i++; + } +} +void print100_10_while() { + int a = 100; + while (a >= 10) { + printf("%d ", a); + a = a - 10; + } +} +void print1000_100_while() { + int a = 1000; + while (a >= 100) { + printf("%d ", a); + a = a - 100; + } +} +void print1000_0_while() { + int a = 1000; + while (a >= 0) { + printf("%d ", a); + a = a - 16; + } +} + + + + + + + + + +void Task1() { + int n, m; + printf("Введите кол-во строк : "); + scanf_s("%d", &n); + printf("Введите кол-во столбцов : "); + scanf_s("%d", &m); + int i = 1; + do { + int j = 1; + do { + int ij = i * 10 + j; + printf("%d ", ij); + j++; + } while (j <= m); + printf("\n"); + i++; + } while (i <= n); +} +void Task2() { + int i = 1; + do { + int j = 1; + do { + int ij = i * j; + printf("%3d ", ij); + j++; + } while (j <= 10); + printf("\n"); + i++; + } while (i <= 10); +} \ No newline at end of file diff --git a/Lab9-10_OAandP/Lab9-10_OAandP.sln b/Lab9-10_OAandP/Lab9-10_OAandP.sln new file mode 100644 index 0000000..f99f915 --- /dev/null +++ b/Lab9-10_OAandP/Lab9-10_OAandP.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35312.102 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lab9-10_OAandP", "Lab9-10_OAandP.vcxproj", "{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Debug|ARM64.Build.0 = Debug|ARM64 + {DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Debug|x64.ActiveCfg = Debug|x64 + {DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Debug|x64.Build.0 = Debug|x64 + {DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Debug|x86.ActiveCfg = Debug|Win32 + {DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Debug|x86.Build.0 = Debug|Win32 + {DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Release|ARM64.ActiveCfg = Release|ARM64 + {DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Release|ARM64.Build.0 = Release|ARM64 + {DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Release|x64.ActiveCfg = Release|x64 + {DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Release|x64.Build.0 = Release|x64 + {DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Release|x86.ActiveCfg = Release|Win32 + {DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {98EF6571-C30A-4B47-8668-A449C51939AD} + EndGlobalSection +EndGlobal diff --git a/Lab9-10_OAandP/Lab9-10_OAandP.vcxproj b/Lab9-10_OAandP/Lab9-10_OAandP.vcxproj new file mode 100644 index 0000000..38b6c64 --- /dev/null +++ b/Lab9-10_OAandP/Lab9-10_OAandP.vcxproj @@ -0,0 +1,190 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM64 + + + Release + ARM64 + + + + 17.0 + Win32Proj + {da530082-7b6b-4ba5-97bf-4f8149fbc0d5} + Lab910OAandP + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + 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 + + + + + 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/Lab9-10_OAandP/Lab9-10_OAandP.vcxproj.filters b/Lab9-10_OAandP/Lab9-10_OAandP.vcxproj.filters new file mode 100644 index 0000000..4ffdf46 --- /dev/null +++ b/Lab9-10_OAandP/Lab9-10_OAandP.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/Lab9-10_OAandP/main.cpp b/Lab9-10_OAandP/main.cpp new file mode 100644 index 0000000..7c685d1 --- /dev/null +++ b/Lab9-10_OAandP/main.cpp @@ -0,0 +1,269 @@ +#include +#include + +#define N_E 10 +int item; +int arr[5]; + +void InputKey() { + printf(" 5 Enter \n"); + for (int i = 0; i < 5; i++) { + printf(" \n"); + scanf_s("%d", &arr[i]); + } + for (int i1 = 0; i1 < 5; i1++) { + printf("%d ", arr[i1]); + } +} + +void x10() { + for (int i = 0; i < 5; i++) { + + if (arr[i] % 2 == 0) { + continue; + } + else { + arr[i] *= 10; + } + } + for (int i1 = 0; i1 < 5; i1++) { + printf("%d ", arr[i1]); + } +} + +int minNum() { + int minNum1 = arr[0]; + int saveNum = 0; + for (int i1 = 0; i1 < 5; i1++) { + if (arr[i1] < minNum1) { + minNum1 = arr[i1]; + + } + + } + return minNum1; +} + +int count10() { + int cnt = 0; + for (int i1 = 0; i1 < 5; i1++) { + if (arr[i1] > 10) { + cnt++; + + } + + } + return cnt; +} + +int x2ForLast() { + int cnt; + for (int i = 4; i >= 0; i--) { + if (arr[i] % 2 == 0) { + cnt = i; + break; + } + } + return cnt; +} + +int findIndexMin() { + int maxNum = 100000000; + int index = 0; + for (int i = 0; i < 5; i++) { + if (arr[i] < maxNum) { + index = i; + maxNum = arr[i]; + } + } + return index; +} + +void seven() { + for (int i = 0; i < 5; i++) { + if (arr[i] % 2 == 0) { + arr[i] *= -1; + } + } + for (int i = 0; i < 5; i++) { + printf("%d ", arr[i]); + } +} +void eight() { + for (int i = 0; i < 5; i++) { + if (arr[i] < 4) { + arr[i] = 4; + } + } + for (int i = 0; i < 5; i++) { + printf("%d ", arr[i]); + } +} + +void nine() { + for (int i = 0; i < 5; i++) { + if (arr[i] % 2 == 0) { + arr[i] = 0; + } + } + for (int i = 0; i < 5; i++) { + printf("%d ", arr[i]); + } +} + +void deleteElement(int ind) { + for (int i = 0; i < 5; i++) { + if (i != ind) { + printf("%d ", arr[i]); + } + } +} + +void insertElement(int index, int value) { + for (int i = 0; i < 5; i++) { + if (index == i) { + printf("%d ", value); + printf("%d ", arr[i]); + } + else { + printf("%d ", arr[i]); + } + } +} +int minNum1() { + int minNum1 = arr[0]; + int saveNum = 0; + for (int i1 = 0; i1 < 5; i1++) { + if (arr[i1] < minNum1) { + minNum1 = arr[i1]; + saveNum = i1; + + } + + } + return saveNum; +} + +void LastTask() { + bool flag = false; + for (int i = 0; i < 5; i++) { + if (arr[i] % 2 == 0 and flag == false) { + flag = true; + continue; + flag = true; + } + else { + printf("%d ", arr[i]); + } + } +} + +void main() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + do { + printf("\n \n"); + printf("1: \n"); + printf("2: x10 \n"); + printf("3: \n"); + printf("4: 10\n"); + printf("5: 2X \n"); + printf("6: \n"); + printf("7: -1\n"); + printf("8: 4 4\n"); + printf("9: \n"); //Var 1 + printf("11: \n"); + printf("12: \n"); + printf("13: \n"); + printf("14: 0\n"); + printf("15: \n"); + printf("\n"); + printf("0: \n"); + + scanf_s("%d", &item); + switch (item) { + case 1: + InputKey(); + break; + case 2: + x10(); + break; + case 3: { + int min = minNum(); + printf("Minimun in %d\n", min); + } + break; + case 4: { + int cnt = count10(); + printf("Total nums higher 10 is %d\n", cnt); + } + break; + case 5: { + int index = x2ForLast(); + if (index >= 0) { + arr[index] *= 2; + printf("That num now is %d", arr[index]); + } + } + break; + + case 6: { + int index1 = findIndexMin(); + printf("Index of min num is %d\n", index1); + + int cnt = 0; + for (int i = 0; i <= index1; i++) { + if (arr[i] % 2 == 0) { + cnt++; + } + } + printf(" %d \n", cnt); + } + break; + case 7: + seven(); + break; + case 8: + eight(); + break; + case 9: + nine(); + break; + case 11: { + printf("Index deleting element = "); + int index1; + scanf_s("%d", &index1); + deleteElement(index1); + break; + } + + case 12: + { + printf(" ? = "); + int index; + scanf_s("%d", &index); + + printf("\n = "); + int value; + scanf_s("%d", &value); + + insertElement(index, value); + break; + } + case 13: { + int min = minNum1(); + deleteElement(min); + break; + } + case 14: { + int min = minNum1(); + insertElement(min, 0); + break; + } + case 15: + LastTask(); + break; + } + + } while (item != 0); +} \ No newline at end of file