diff --git a/лаба 15.sln b/лаба 15.sln new file mode 100644 index 0000000..b9d4a25 --- /dev/null +++ b/лаба 15.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}") = "лаба 15", "лаба 15\лаба 15.vcxproj", "{7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}" +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 + {7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Debug|x64.ActiveCfg = Debug|x64 + {7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Debug|x64.Build.0 = Debug|x64 + {7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Debug|x86.ActiveCfg = Debug|Win32 + {7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Debug|x86.Build.0 = Debug|Win32 + {7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Release|x64.ActiveCfg = Release|x64 + {7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Release|x64.Build.0 = Release|x64 + {7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Release|x86.ActiveCfg = Release|Win32 + {7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {307B325D-0651-4005-9068-C50F6AA6EEB4} + EndGlobalSection +EndGlobal diff --git a/лаба 15/FileName.cpp b/лаба 15/FileName.cpp new file mode 100644 index 0000000..de95f88 --- /dev/null +++ b/лаба 15/FileName.cpp @@ -0,0 +1,267 @@ +#include +#include + +#define MAX_N 8 +#define MAX_M 10 + +int arr[MAX_N][MAX_M] = { + { 0, 1, 222, 3}, + {10, 11, 12, 13}, + {20, 21, 22, 23} +}; +int n = 3; +int m = 4; + +void print() { + 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 print0() { + print(); +} + + + + +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 print1() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + fillIx10(); + +} + + + + +void fillZero() { + printf("!!!! fillZero() !!!!\n"); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + arr[i][j] = 0; + } + } +} + +void print2() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + + + fillZero(); + +} + + + + + +void randFill0_9() { + printf("!!!! randFill() !!!!\n"); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + arr[i][j] = rand() % 100; + } + } +} + +void print3() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + + randFill0_9(); + +} + +void proizvedenie() { + printf("!!!! *10() !!!!\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 print4() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + + proizvedenie(); + +} + + +void delenie() { + printf("!!!! *10() !!!!\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 print5() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + + delenie(); + +} + +int vvod() { + + // + printf(" (%d x %d):\n", n, m); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + printf(" [%d][%d]: \n", i, j); + scanf_s("%d", &arr[i][j]); // + } + } + + // + printf(" :\n"); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + printf("%d ", arr[i][j]); // + } + printf("\n"); + } + + return 0; +} + +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 print7() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + int num; + printf(" , : "); + scanf_s("%d", &num); + deleteRow(num); +} + +void save() { + // + FILE* fout = NULL; + errno_t err = fopen_s(&fout, "C:\\Users\\home-PC\\Desktop\\\\arr11.txt", "wt"); + if (err != 0 || fout == NULL) { + printf(" \n"); + 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 = NULL; + errno_t err = fopen_s(&fin, "C:\\Users\\home-PC\\Desktop\\\\arr11.txt", "rt"); + if (err != 0 || fin == NULL) { + printf(" \n"); + 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 main() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + int item; + do { + printf("\n"); + print(); + printf("------------------------------\n"); + printf(" :\n"); + printf("1: i*10+j \n"); + printf("2: \n"); + printf("3: 100\n"); + printf("4: 10 \n"); + printf("5: 10 10 \n"); + printf("6: \n"); + printf("7: \n"); + printf("8: \n"); + printf("9: \n"); + printf("\n"); + printf("0: \n"); + printf(" >>>>>> "); + + scanf_s("%d", &item); + switch (item) { + case 1: + print1(); + break; + case 2: + print2(); + break; + + case 3: + print3(); + break; + case 4: + print4(); + break; + case 5: + print5(); + break; + case 6: + vvod(); + break; + case 7: + print7(); + break; + case 8: + save(); + break; + case 9: + load(); + break; + } + } while (item != 0); +} \ No newline at end of file diff --git a/лаба 15/лаба 15.vcxproj b/лаба 15/лаба 15.vcxproj new file mode 100644 index 0000000..adf5735 --- /dev/null +++ b/лаба 15/лаба 15.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {7db8af7b-4be0-4c8d-9cbd-a0ed7c7ce87b} + лаба15 + 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/лаба 15/лаба 15.vcxproj.filters b/лаба 15/лаба 15.vcxproj.filters new file mode 100644 index 0000000..f958bbd --- /dev/null +++ b/лаба 15/лаба 15.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