diff --git a/Lab_15/Lab15.cpp b/Lab_15/Lab15.cpp new file mode 100644 index 0000000..2397999 --- /dev/null +++ b/Lab_15/Lab15.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 diff --git a/Lab_15/arr.txt b/Lab_15/arr.txt new file mode 100644 index 0000000..e69de29 diff --git a/Lab_15/Лаба 15.vcxproj b/Lab_15/Лаба 15.vcxproj new file mode 100644 index 0000000..27d0249 --- /dev/null +++ b/Lab_15/Лаба 15.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {06254d4b-3381-4277-a25a-4f6cc77cc193} + Лаба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 + _CRT_SECURE_NO_WARNINGS + 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_15/Лаба 15.vcxproj.filters b/Lab_15/Лаба 15.vcxproj.filters new file mode 100644 index 0000000..2fc5505 --- /dev/null +++ b/Lab_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 diff --git a/lab17/lab17.c b/lab17/lab17.c new file mode 100644 index 0000000..e69de29 diff --git a/lab17/lab17.vcxproj b/lab17/lab17.vcxproj new file mode 100644 index 0000000..3e65b28 --- /dev/null +++ b/lab17/lab17.vcxproj @@ -0,0 +1,138 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + 17.0 + Win32Proj + {965f45b5-e28e-41da-8c5f-187fdea2423b} + lab17 + 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 + + + + + + + + diff --git a/lab17/lab17.vcxproj.filters b/lab17/lab17.vcxproj.filters new file mode 100644 index 0000000..153170c --- /dev/null +++ b/lab17/lab17.vcxproj.filters @@ -0,0 +1,17 @@ + + + + + {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