From 58817ebbe4b6a7fe14905c3b9096c1e70da55bfe Mon Sep 17 00:00:00 2001 From: sqdselo Date: Thu, 31 Oct 2024 12:06:26 +0400 Subject: [PATCH] First --- Project1/Project1.sln | 31 +++ Project1/Project1/Project1.vcxproj | 135 ++++++++++++ Project1/Project1/Project1.vcxproj.filters | 22 ++ Project1/Project1/Source.cpp | 236 +++++++++++++++++++++ 4 files changed, 424 insertions(+) create mode 100644 Project1/Project1.sln create mode 100644 Project1/Project1/Project1.vcxproj create mode 100644 Project1/Project1/Project1.vcxproj.filters create mode 100644 Project1/Project1/Source.cpp diff --git a/Project1/Project1.sln b/Project1/Project1.sln new file mode 100644 index 0000000..39c2015 --- /dev/null +++ b/Project1/Project1.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34616.47 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project1", "Project1\Project1.vcxproj", "{CEC4D39C-2D51-4872-88FE-4A01750DFC0A}" +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 + {CEC4D39C-2D51-4872-88FE-4A01750DFC0A}.Debug|x64.ActiveCfg = Debug|x64 + {CEC4D39C-2D51-4872-88FE-4A01750DFC0A}.Debug|x64.Build.0 = Debug|x64 + {CEC4D39C-2D51-4872-88FE-4A01750DFC0A}.Debug|x86.ActiveCfg = Debug|Win32 + {CEC4D39C-2D51-4872-88FE-4A01750DFC0A}.Debug|x86.Build.0 = Debug|Win32 + {CEC4D39C-2D51-4872-88FE-4A01750DFC0A}.Release|x64.ActiveCfg = Release|x64 + {CEC4D39C-2D51-4872-88FE-4A01750DFC0A}.Release|x64.Build.0 = Release|x64 + {CEC4D39C-2D51-4872-88FE-4A01750DFC0A}.Release|x86.ActiveCfg = Release|Win32 + {CEC4D39C-2D51-4872-88FE-4A01750DFC0A}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {846B881A-0D5D-408E-9405-DB722494885E} + EndGlobalSection +EndGlobal diff --git a/Project1/Project1/Project1.vcxproj b/Project1/Project1/Project1.vcxproj new file mode 100644 index 0000000..3345ed3 --- /dev/null +++ b/Project1/Project1/Project1.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {cec4d39c-2d51-4872-88fe-4a01750dfc0a} + Project1 + 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/Project1/Project1/Project1.vcxproj.filters b/Project1/Project1/Project1.vcxproj.filters new file mode 100644 index 0000000..ef66db6 --- /dev/null +++ b/Project1/Project1/Project1.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/Project1/Project1/Source.cpp b/Project1/Project1/Source.cpp new file mode 100644 index 0000000..042edb3 --- /dev/null +++ b/Project1/Project1/Source.cpp @@ -0,0 +1,236 @@ +#include +#include +#define _CRT_SECURE_NO_WARNINGS +#define NUM_ELEMENTS 100 + +int arr[NUM_ELEMENTS][NUM_ELEMENTS]; +int n = 3, m = 4; + +void print_arr() { + printf("!!!! print() !!!!\n"); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + printf("%3d ", arr[i][j]); + } + printf("\n"); + } + +} +void fillIx10() { + printf("!!!! fillIx10() !!!!\n"); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + arr[i][j] = i * 10 + j; + } + } +} +void fillZero() { + printf("!!!! fillZero() !!!!\n"); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + arr[i][j] = 0; + } + } +} +void randFill0_9() { + printf("!!!! randFill0_9() !!!!\n"); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + arr[i][j] = rand() % 10; + } + } +} + +void deleteRow(int delRow) { + printf("!!!! deleteRow(%d) !!!!\n", delRow); + for (int i = delRow; i < n - 1; i++) { + for (int j = 0; j < m; j++) { + arr[i][j] = arr[i + 1][j]; + } + } + n--; +} +void save() { + FILE* fout = fopen("C:\\temp\\arr1.txt", "wt"); + if (fout == NULL) { + printf(" "); + return; + } + + fprintf(fout, "%d ", n); + fprintf(fout, "%d\n", m); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + fprintf(fout, "%d ", arr[i][j]); + } + fprintf(fout, "\n"); + } + + fclose(fout); +} +void load() { + + FILE* fin = fopen("C:\\temp\\arr1.txt", "rt"); + if (fin == NULL) { + printf(" "); + return; + } + + fscanf_s(fin, "%d", &n); + fscanf_s(fin, "%d", &m); + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + fscanf_s(fin, "%d", &arr[i][j]); + } + } + + fclose(fin); +} + +void duplicateColumn(int colIndex) { + printf("!!!! duplicateColumn() !!!!\n"); + for (int i = 0; i < n; i++) { + arr[i][m] = arr[i][colIndex]; + } + m++; +} + + +void inputA() { + printf(" (n): "); + scanf_s("%d", &n); + + printf(" (m): "); + scanf_s("%d", &m); + printf(" :\n"); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + printf("arr[%d][%d]: ", i, j); + scanf_s("%d", &arr[i][j]); + } + } +} +void oddnumx10() { + printf("!!!! oddnumx10 !!!!\n"); + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + if (arr[i][j] % 2 != 0) { + arr[i][j] *= 10; + } + } + } +} +void multiples10() { + printf("!!!! multiples10 !!!!\n"); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + if (arr[i][j] % 10 == 0) { + arr[i][j] /= 10; + } + } + } +} +void func_11() { + int min, max, min_i, min_j; + min = arr[0][0]; max = arr[0][0]; + min_i = 0; min_j = 0; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + if (arr[i][j] < min) { + min = arr[i][j]; + min_i = i; + min_j = j; + } + if (arr[i][j] > max) { + max = arr[i][j]; + } + } + } + + int mean; + mean = (max + min) / 2; + + for (int i = 0; i < min_i; i++) { + for (int j = 0; j < min_j; j++) { + arr[i][j] = mean; + } + } +} +void menu1() { + printf("\n"); + printf("------------------------------\n"); + printf(" :\n"); + printf("1: i * 10 + j\n"); + printf("2: \n"); + printf("3: \n"); + printf("4: 10 \n"); + printf("5: 10 10 \n"); + printf("6: \n"); + printf("7: \n"); + printf("8: \n"); + printf("9: \n"); + printf("10: \n"); + printf("11: , min \n"); + printf(" min max \n"); + printf("\n"); + printf("-1: \n"); + printf(" >>>>>> "); +} +void main() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + int item; + do { + print_arr(); + menu1(); + scanf_s("%d", &item); + printf("\n"); + switch (item) { + case 9: { + int num; + printf(" , : "); + scanf_s("%d", &num); + deleteRow(num); + } + break; + case 7: + save(); + break; + case 10: { + printf(" , : "); + int c; + scanf_s("%d", &c); + duplicateColumn(c); + } + break; + case 1: + fillIx10(); + break; + case 2: + fillZero(); + break; + case 3: + randFill0_9(); + break; + case 6: + inputA(); + break; + case 5: + multiples10(); + break; + case 4: + oddnumx10(); + break; + case 8: + load(); + break; + case 11: + func_11(); + break; + } + + } while (item != -1); +} \ No newline at end of file