diff --git a/1314/1314.sln b/1314/1314.sln new file mode 100644 index 0000000..f9fd020 --- /dev/null +++ b/1314/1314.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}") = "1314", "1314\1314.vcxproj", "{947F958C-148D-47F9-B966-B3182EF5C2EE}" +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 + {947F958C-148D-47F9-B966-B3182EF5C2EE}.Debug|x64.ActiveCfg = Debug|x64 + {947F958C-148D-47F9-B966-B3182EF5C2EE}.Debug|x64.Build.0 = Debug|x64 + {947F958C-148D-47F9-B966-B3182EF5C2EE}.Debug|x86.ActiveCfg = Debug|Win32 + {947F958C-148D-47F9-B966-B3182EF5C2EE}.Debug|x86.Build.0 = Debug|Win32 + {947F958C-148D-47F9-B966-B3182EF5C2EE}.Release|x64.ActiveCfg = Release|x64 + {947F958C-148D-47F9-B966-B3182EF5C2EE}.Release|x64.Build.0 = Release|x64 + {947F958C-148D-47F9-B966-B3182EF5C2EE}.Release|x86.ActiveCfg = Release|Win32 + {947F958C-148D-47F9-B966-B3182EF5C2EE}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2A42C0D5-BA61-4AB4-A907-EFE4AB71565A} + EndGlobalSection +EndGlobal diff --git a/1314/1314/1314.vcxproj b/1314/1314/1314.vcxproj new file mode 100644 index 0000000..aa75782 --- /dev/null +++ b/1314/1314/1314.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {947f958c-148d-47f9-b966-b3182ef5c2ee} + My1314 + 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/1314/1314/1314.vcxproj.filters b/1314/1314/1314.vcxproj.filters new file mode 100644 index 0000000..ef66db6 --- /dev/null +++ b/1314/1314/1314.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/1314/1314/Source.cpp b/1314/1314/Source.cpp new file mode 100644 index 0000000..7f51fa8 --- /dev/null +++ b/1314/1314/Source.cpp @@ -0,0 +1,296 @@ +#include +#include +#define NUM_ELEMENTS 10 + +int arr[NUM_ELEMENTS]; +int n = 0; + +void printElements() { + printf("< "); + for (int i = 0; i < n; i++) { + printf("%d ", arr[i]); + } + printf(">\n"); +} + +void keyboardInput() { + printf("n = "); + scanf_s("%d", &n); + printf("input %d values: ", 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 = 0; i < n; i++) { + if (arr[i] < min) { + min = arr[i]; + } + } + return min; +} +void printArray() { + printf(" : "); + for (int i = 0; i < n; i++) { + printf("%d ", arr[i]); + } + printf("\n"); +} + +void print_10() { + int p = 0; + for (int i = 0; i < n; i++) { + if (arr[i] > 10) { + p++; + } + + } + printf("%d", p); + +} +void doubleLastEven() { + for (int i = n - 1; i >= 0; i--) { + if (arr[i] % 2 == 0) { + arr[i] *= 2; + printf(" %d \n", arr[i]); + return; + } + } + printf(" .\n"); +} + +int countEvensLeftOfMin() { + int min = findMin(); + int cnt = 0; + for (int i = 0; i < n; i++) { + if (arr[i] == min) { + break; // , + } + if (arr[i] % 2 == 0) { + cnt++; // , + } + } + return cnt; +} + +void deleteElement(int delIndex) { + for (int i = delIndex; i < n - 1; i++) { + arr[i] = arr[i + 1]; + } + n--; +} + +void insertElement(int insIndex, int value) { + for (int i = n; i > insIndex; i--) { + arr[i] = arr[i - 1]; + } + n++; + arr[insIndex] = value; +} + +void deleteMinElement() { + int min = findMin(); + int minIndex = -1; + + // + for (int i = 0; i < n; i++) { + if (arr[i] == min) { + minIndex = i; + break; // + } + } + + if (minIndex != -1) { + deleteElement(minIndex); + printf(" %d .\n", min); + } + else { + printf(" .\n"); + } +} +int findFirstOdd() +{ + int even = -1; + for (int i = 0; i < n; i++) + { + if ((arr[i] + 2) % 2 != 0) + { + if (even == -1) + { + even = i; + } + } + } + return even; +} +void option1() { + for (int i = 1; i < n; ++i) { + if (arr[i] % 2 == 0) { + arr[i - 1] = 9; + } + } +} +int findMinimum() { + int min = arr[0]; + int index = 0; + for (int i = 1; i < n; i++) + { + if (arr[i] < min) + { + min = i; + index = i; + } + } + return index; +} + + + + +void main() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + int item, index, even; + do { + printf("\n"); + printf("------------------------------\n"); + printf(" :"); + printElements(); + printf(" :\n"); + printf("1: \n"); + printf("2: x10 \n"); + printf("3: \n"); + printf("4: > 10\n"); + printf("5: 2 \n"); + printf("6: \n"); + printf("8: "); + //14 + printf("7: \n"); + printf("8: \n"); + printf("9: \n"); + printf("10: \n"); + printf("11: 9\n"); + printf("12: -1\n"); + printf("13: 4 4\n"); + printf("14: 0\n"); + printf("\n"); + printf("0: \n"); + printf(" >>>>>> "); + + scanf_s("%d", &item); + switch (item) { + case 1: + keyboardInput(); + break; + + case 2: + oddsX10(); + printArray(); + break; + + case 3: + { + int min = findMin(); + printf("min = %d\n", min); + } + break; + case 4: + print_10(); + break; + case 5: + doubleLastEven(); + break; + + case 6: + { + int cnt = countEvensLeftOfMin(); + printf(" : %d\n", cnt); + break; + } + case 7: + { + printf(" = "); + int index; + scanf_s("%d", &index); + + deleteElement(index); + printArray(); + + break; + } + + case 8: + { + printf(" . = "); + int index; + scanf_s("%d", &index); + + printf(", = "); + int value; + scanf_s("%d", &value); + insertElement(index, value); + + + printArray(); + break; + + + case 9: + + deleteMinElement(); + printArray(); + break; + + + + + } + case 10: + + index = findFirstOdd(); + even = index; + printf(" %d\n", even); + deleteElement(index); + break; + + case 11: + option1(); + break; + + + case 12: + for (int i = 0; i < n; i++) + { + if (arr[i] % 2 == 0) + { + arr[i] *= -1; + } + } + break; + + case 13: + for (int i = 0; i < n; i++) + { + if (arr[i] < 4) + { + arr[i] = 4; + } + } + break; + + case 14: // 0 + index = findMinimum(); + printf(" : %d", index); + insertElement(index, 0); + break; + } + } while (item != 0); +}