diff --git a/11/11.cpp b/11/11.cpp new file mode 100644 index 0000000..0704d38 --- /dev/null +++ b/11/11.cpp @@ -0,0 +1,341 @@ +// 11.cpp : Определяет точку входа для приложения. +// + +#include "stdio.h" +#include "framework.h" +#include "11.h" +#include "time.h" + + +//TODO: мои зависимости +#include "Function.h" +enum images image_now = (enum images)0; + +COLORREF colors1[9] = { + RGB(255,0,0), + RGB(255,127,0), + RGB(255,255,0), + RGB(127,255,0), + RGB(0,255,0), + RGB(0,255,127), + RGB(0,255,255), + RGB(0,127,255), + RGB(0,0,255), +}; + +#define L12 +const int v = 10; + +IMAGE img = { 20,20,v,v,RGB(255,0,255),arrow }; + +IMAGE imgs[4] = { + { 420,220,v,0,RGB(0,0,0),triangle }, + { 420,220,-v,0,RGB(255,0,0),diamond }, + { 420,220,0,v,RGB(0,0,255),crown }, + { 420,220,0,-v,RGB(0,255,0),flag }, +}; + + +#define MAX_LOADSTRING 100 + +// Глобальные переменные: +HINSTANCE hInst; // текущий экземпляр +WCHAR szTitle[MAX_LOADSTRING]; // Текст строки заголовка +WCHAR szWindowClass[MAX_LOADSTRING]; // имя класса главного окна + +// Отправить объявления функций, включенных в этот модуль кода: +ATOM MyRegisterClass(HINSTANCE hInstance); +BOOL InitInstance(HINSTANCE, int); +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); + +int APIENTRY wWinMain(_In_ HINSTANCE hInstance, + _In_opt_ HINSTANCE hPrevInstance, + _In_ LPWSTR lpCmdLine, + _In_ int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + + // TODO: Разместите код здесь. + + // Инициализация глобальных строк + LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + LoadStringW(hInstance, IDC_MY1112, szWindowClass, MAX_LOADSTRING); + MyRegisterClass(hInstance); + + // Выполнить инициализацию приложения: + if (!InitInstance (hInstance, nCmdShow)) + { + return FALSE; + } + + HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MY1112)); + + MSG msg; + + // Цикл основного сообщения: + while (GetMessage(&msg, nullptr, 0, 0)) + { + if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + return (int) msg.wParam; +} + + + +// +// ФУНКЦИЯ: MyRegisterClass() +// +// ЦЕЛЬ: Регистрирует класс окна. +// +ATOM MyRegisterClass(HINSTANCE hInstance) +{ + WNDCLASSEXW wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MY1112)); + wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_MY1112); + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); + + return RegisterClassExW(&wcex); +} + +// +// ФУНКЦИЯ: InitInstance(HINSTANCE, int) +// +// ЦЕЛЬ: Сохраняет маркер экземпляра и создает главное окно +// +// КОММЕНТАРИИ: +// +// В этой функции маркер экземпляра сохраняется в глобальной переменной, а также +// создается и выводится главное окно программы. +// +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + hInst = hInstance; // Сохранить маркер экземпляра в глобальной переменной + + HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr); + + if (!hWnd) + { + return FALSE; + } + + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + return TRUE; +} + +// +// ФУНКЦИЯ: WndProc(HWND, UINT, WPARAM, LPARAM) +// +// ЦЕЛЬ: Обрабатывает сообщения в главном окне. +// +// WM_COMMAND - обработать меню приложения +// WM_PAINT - Отрисовка главного окна +// WM_DESTROY - отправить сообщение о выходе и вернуться +// +// +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_COMMAND: + { + int wmId = LOWORD(wParam); + // Разобрать выбор в меню: + switch (wmId) + { + case IDM_ABOUT: + DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); + break; + case IDM_EXIT: + DestroyWindow(hWnd); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + } + break; + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdc = BeginPaint(hWnd, &ps); + // TODO: Добавьте сюда любой код прорисовки, использующий HDC... + +#ifndef L12 + void (*d[5])(HDC, int, int, COLORREF) = { + triangle, + arrow, + diamond, + flag, + crown + }; + + pattern1(hdc, (*d[image_now])); +#endif + +#ifdef L12 + img.func(hdc, img.x, img.y, img.color); + for (int i = 0; i < 4; i++) { + imgs[i].func(hdc, imgs[i].x, imgs[i].y, imgs[i].color); + } +#endif + + + EndPaint(hWnd, &ps); + } + break; + +#ifdef L12 + case WM_CREATE: + SetTimer(hWnd, 1, 40, 0); + SetTimer(hWnd, 2, 100, 0); + srand(time(NULL)); + break; + case WM_TIMER: + + switch (wParam) { + case 1: + RECT rect; + + GetClientRect(hWnd, &rect); + + if (img.x + 20 > rect.right) { + img.vx = -v; + } + + if (img.x - 20 < rect.left) { + img.vx = v; + } + + if (img.y + 20 > rect.bottom) { + img.vy = -v; + } + + if (img.y - 20 < rect.top) { + img.vy = v; + } + + img.x += img.vx; + img.y += img.vy; + + + + for (int i = 0; i < 4; i++) { + if (imgs[i].x + 20 > rect.right) { + imgs[i].vx = -v; + } + + if (imgs[i].x - 20 < rect.left) { + imgs[i].vx = v; + } + + if (imgs[i].y + 20 > rect.bottom) { + imgs[i].vy = -v; + } + + if (imgs[i].y - 20 < rect.top) { + imgs[i].vy = v; + } + + imgs[i].x += imgs[i].vx; + imgs[i].y += imgs[i].vy; + } + break; + case 2: + //img.color = colors1[rand() % 9]; + img.color = RGB(rand()%256, rand()%256, rand()%256); + for (int i = 0; i < 4; i++) { + imgs[i].color = RGB(rand() % 256, rand() % 256, rand() % 256); + } + break; + } + + + + InvalidateRect(hWnd, NULL, TRUE); + break; + + break; +#endif + + case WM_KEYDOWN: + switch (wParam) + { + case VK_RIGHT: + image_now = (enum images)(image_now + 1); + break; + case VK_LEFT: + image_now = (enum images)(image_now - 1); + break; + } +#ifndef L12 + if (image_now > 4 ) { + image_now = (enum images)0; + } + if (image_now < 0) { + image_now = (enum images)3; + } +#endif +#ifdef L12 + if (image_now > 8) { + image_now = (enum images)0; + } + if (image_now < 0) { + image_now = (enum images)8; + } +#endif + + + + //RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE); + InvalidateRect(hWnd, NULL, TRUE); + + + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} + +// Обработчик сообщений для окна "О программе". +INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + UNREFERENCED_PARAMETER(lParam); + switch (message) + { + case WM_INITDIALOG: + return (INT_PTR)TRUE; + + case WM_COMMAND: + if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) + { + EndDialog(hDlg, LOWORD(wParam)); + return (INT_PTR)TRUE; + } + break; + } + return (INT_PTR)FALSE; +} diff --git a/11/11.h b/11/11.h new file mode 100644 index 0000000..b798bf5 --- /dev/null +++ b/11/11.h @@ -0,0 +1,3 @@ +#pragma once + +#include "resource.h" diff --git a/11/11.ico b/11/11.ico new file mode 100644 index 0000000..b3ec03b Binary files /dev/null and b/11/11.ico differ diff --git a/11/11.rc b/11/11.rc new file mode 100644 index 0000000..c77388b Binary files /dev/null and b/11/11.rc differ diff --git a/11/11.vcxproj b/11/11.vcxproj new file mode 100644 index 0000000..4c521f1 --- /dev/null +++ b/11/11.vcxproj @@ -0,0 +1,151 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {fd72aa5a-14f6-4851-83a9-b1d6948b0c86} + My1112 + 10.0 + 11 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Level3 + true + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/11/11.vcxproj.filters b/11/11.vcxproj.filters new file mode 100644 index 0000000..1aaeb40 --- /dev/null +++ b/11/11.vcxproj.filters @@ -0,0 +1,55 @@ + + + + + {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/11/Function.cpp b/11/Function.cpp new file mode 100644 index 0000000..d023148 --- /dev/null +++ b/11/Function.cpp @@ -0,0 +1,116 @@ +#include "Function.h" + +void triangle(HDC hdc, int x, int y, COLORREF color) { + HPEN hpen = CreatePen(PS_SOLID, 2, color); + SelectObject(hdc, hpen); + SelectObject(hdc, GetStockObject(NULL_BRUSH)); + + POINT pt[3] = { + {x,y - 20}, + {x + 20,y + 20}, + {x - 20, y + 20} + }; + + Polygon(hdc, pt, 3); + + DeleteObject(hpen); + SelectObject(hdc, GetStockObject(DC_PEN)); + SelectObject(hdc, GetStockObject(DC_BRUSH)); +} + +void arrow(HDC hdc, int x, int y, COLORREF color) { + HPEN hpen = CreatePen(PS_SOLID, 2, color); + SelectObject(hdc, hpen); + SelectObject(hdc, GetStockObject(NULL_BRUSH)); + + POINT pt[4] = { + {x, y}, + {x + 20, y - 20}, + {x, y + 20}, + {x - 20, y - 20} + }; + + Polygon(hdc, pt, 4); + + DeleteObject(hpen); + SelectObject(hdc, GetStockObject(DC_PEN)); + SelectObject(hdc, GetStockObject(DC_BRUSH)); +} + +void diamond(HDC hdc, int x, int y, COLORREF color) { + HPEN hpen = CreatePen(PS_SOLID, 2, color); + SelectObject(hdc, hpen); + SelectObject(hdc, GetStockObject(NULL_BRUSH)); + + POINT pt[4] = { + {x, y - 20}, + {x + 20, y}, + {x, y + 20}, + {x - 20, y} + }; + + Polygon(hdc, pt, 4); + + DeleteObject(hpen); + SelectObject(hdc, GetStockObject(DC_PEN)); + SelectObject(hdc, GetStockObject(DC_BRUSH)); +} + +void flag(HDC hdc, int x, int y, COLORREF color) { + HPEN hpen = CreatePen(PS_SOLID, 2, color); + SelectObject(hdc, hpen); + + POINT pt[6] = { + {x - 20, y}, + {x + 20, y}, + {x, y - 10}, + {x + 20, y - 20}, + {x - 20, y - 20}, + {x - 20, y + 20} + }; + + Polyline(hdc, pt, 6); + + DeleteObject(hpen); + SelectObject(hdc, GetStockObject(DC_PEN)); +} + +void crown(HDC hdc, int x, int y, COLORREF color) { + HPEN hpen = CreatePen(PS_SOLID, 2, color); + SelectObject(hdc, hpen); + SelectObject(hdc, GetStockObject(NULL_BRUSH)); + + POINT pt[5] = { + {x, y}, + {x + 20, y - 20}, + {x + 20, y + 20}, + {x - 20, y + 20}, + {x - 20, y - 20}, + }; + + Polygon(hdc, pt, 5); + + DeleteObject(hpen); + SelectObject(hdc, GetStockObject(DC_PEN)); + SelectObject(hdc, GetStockObject(DC_BRUSH)); +} + +void pattern1(HDC hdc, void (*f)(HDC, int, int, COLORREF)) { + COLORREF colors[Length] = { + RGB(255,0,0), + RGB(0,255,0), + RGB(0,0,255), + RGB(255,0,255), + RGB(255,255,0) + }; + POINT pt[Length] = { + {40,40}, + {240,40}, + {440,40}, + {40,240}, + {440,240} + }; + for (int i = 0; i < Length; i++) { + (*f)(hdc, pt[i].x, pt[i].y, colors[i]); + } +} \ No newline at end of file diff --git a/11/Function.h b/11/Function.h new file mode 100644 index 0000000..fa331f8 --- /dev/null +++ b/11/Function.h @@ -0,0 +1,31 @@ +#pragma once + +#include + +#define Length 5 + +enum images { + i_triangle, + i_arrow, + i_diamond, + i_flag, + i_crown +}; + +typedef struct Image_cords { + int x; + int y; + int vx; + int vy; + COLORREF color; + void (*func)(HDC, int, int, COLORREF); +} IMAGE; + +void triangle(HDC hdc, int x, int y, COLORREF color); +void arrow(HDC hdc, int x, int y, COLORREF color); +void diamond(HDC hdc, int x, int y, COLORREF color); +void flag(HDC hdc, int x, int y, COLORREF color); +void crown(HDC hdc, int x, int y, COLORREF color); + +void pattern1(HDC hdc, void (*f)(HDC, int, int, COLORREF)); + diff --git a/11/Resource.h b/11/Resource.h new file mode 100644 index 0000000..0068fc4 --- /dev/null +++ b/11/Resource.h @@ -0,0 +1,30 @@ +//{{NO_DEPENDENCIES}} +// Включаемый файл, созданный в Microsoft Visual C++. +// Используется 11-12.rc + +#define IDS_APP_TITLE 103 + +#define IDR_MAINFRAME 128 +#define IDD_MY1112_DIALOG 102 +#define IDD_ABOUTBOX 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDI_MY1112 107 +#define IDI_SMALL 108 +#define IDC_MY1112 109 +#define IDC_MYICON 2 +#ifndef IDC_STATIC +#define IDC_STATIC -1 +#endif +// Следующие стандартные значения для новых объектов +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS + +#define _APS_NO_MFC 130 +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/11/desktop.ini b/11/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/11/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/11/framework.h b/11/framework.h new file mode 100644 index 0000000..a8f6dc8 --- /dev/null +++ b/11/framework.h @@ -0,0 +1,15 @@ +// header.h: включаемый файл для стандартных системных включаемых файлов +// или включаемые файлы для конкретного проекта +// + +#pragma once + +#include "targetver.h" +#define WIN32_LEAN_AND_MEAN // Исключите редко используемые компоненты из заголовков Windows +// Файлы заголовков Windows +#include +// Файлы заголовков среды выполнения C +#include +#include +#include +#include diff --git a/11/small.ico b/11/small.ico new file mode 100644 index 0000000..b3ec03b Binary files /dev/null and b/11/small.ico differ diff --git a/11/targetver.h b/11/targetver.h new file mode 100644 index 0000000..d90003d --- /dev/null +++ b/11/targetver.h @@ -0,0 +1,6 @@ +#pragma once + +// // При включении SDKDDKVer.h будет задана самая новая из доступных платформ Windows. +// Если вы планируете сборку приложения для предыдущей версии платформы Windows, включите WinSDKVer.h и +// задайте желаемую платформу в макросе _WIN32_WINNT, прежде чем включать SDKDDKVer.h. +#include diff --git a/13-14/13-14.vcxproj b/13-14/13-14.vcxproj new file mode 100644 index 0000000..ce9b85f --- /dev/null +++ b/13-14/13-14.vcxproj @@ -0,0 +1,139 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {161816fb-da2b-43f7-8cfe-2f3a03bf2f97} + 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/13-14/13-14.vcxproj.filters b/13-14/13-14.vcxproj.filters new file mode 100644 index 0000000..1b6f62e --- /dev/null +++ b/13-14/13-14.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {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/13-14/Function.c b/13-14/Function.c new file mode 100644 index 0000000..c8c885a --- /dev/null +++ b/13-14/Function.c @@ -0,0 +1,266 @@ +#include "Function.h" + +int arr[DEFAULT_LENGHT]; +int lenght = 0; + +Element getMax(), getMin(); + +//13 +void setArray() { + printf("n = "); + scanf_s("%d", &lenght); + + printf(" %d : ", lenght); + for (int i = 0; i < lenght; i++) { + scanf_s("%d", &arr[i]); + } +} + +void oddX10() { + for (int i = 0; i < lenght; i++) { + if (arr[i] % 2 != 0) { + arr[i] *= 10; + } + } +} + +int countGreaterThen(int greater) { + int k = 0; + for (int i = 0; i < lenght; i++) { + if (arr[i] > greater) { + k++; + } + } + return k; +} + +void timesLastEven(int times) { + for (int i = lenght-1; i >= 0; i--) { + if (arr[i] % 2 == 0) { + arr[i] *= times; + break; + } + } +} + +int countEvenLeftOfMin() { + Element min = getMin(); + + int k = 0; + for (int i = 0; i < min.index; i++) { + if (arr[i] % 2 == 0) { + k++; + } + } + return k; +} + +void timesOddRightOfMin(int times) { + Element min = getMin(); + for (int i = min.index + 1; i < lenght; i++) { + if (arr[i] % 2 != 0) { + arr[i] *= times; + } + } +} + +void ReplaceMinMax() { + Element minGet = getMin(); + Element maxGet = getMax(); + arr[minGet.index] = maxGet.value; + arr[maxGet.index] = minGet.value; +} + +void allEven(int times) { + for (int i = 0; i < lenght; i++) { + if (arr[i] % 2 == 0) arr[i] *= times; + } +} + +void allLess4() { + for (int i = 0; i < lenght; i++) { + if (arr[i] < 4) arr[i] = 4; + } +} + +void right0() { + Element max = getMax(); + for (int i = max.index + 1; i < lenght; i++) { + arr[i] = 0; + } +} + +Element getMin() { + int min = arr[0]; + int index = 0; + for (int i = 1; i < lenght; i++) { + if (arr[i] < min) { + min = arr[i]; + index = i; + } + } + + Element answer = { min, index }; + + return answer; +} + +Element getMax() { + int max = arr[0]; + int index = 0; + for (int i = 1; i < lenght; i++) { + if (arr[i] > max) { + max = arr[i]; + index = i; + } + } + + Element answer = { max, index }; + + return answer; +} + +//14 +void deleteElement(int index) { + if (! (index >= 0 && index <= lenght)) { + return; + } + + lenght -= 1; + + for (int i = index; i < lenght; i++) { + arr[i] = arr[i+1]; + } + +} + +void insertElement(int value, int index) { + if (! (index >= 0 && index <= lenght)) { + return; + } + + for (int i = lenght; i >index; i--) { + arr[i] = arr[i-1]; + } + lenght += 1; + arr[index] = value; +} + +void printArr() { + printf("< "); + for (int i = 0; i < lenght; i++) { + printf("%d ", arr[i]); + } + printf(">\n"); +} + +void menuText() { + printf("\n\n"); + if (lenght != 0) { + printf(": %d\n", lenght); + printArr(); + } + printf("--------------\n"); + printf(" :\n"); + printf("1) \n"); + printf("2) 10 \n"); + printf("3) \n"); + printf("4) > 10\n"); + printf("5) 2 \n"); + printf("6) \n"); + printf("7) 10 \n"); + printf("8) min max\n"); + printf("9) x-1\n"); + printf("10) 4 el<4\n"); + printf("11) el>>max 0\n"); + printf("21) \n"); + printf("22) \n"); + printf("23) \n"); + printf("24) 0\n"); + printf("25) \n"); + printf("\n"); + printf("0) \n"); + printf(" >>> "); +} + +void startProg() { + int ans; + int ind, value; + do { + menuText(); + scanf_s("%d", &ans); + + switch (ans) + { + case 1: + setArray(); + break; + case 2: + oddX10(); + break; + case 3: + printf("min = %d", getMin().index); + break; + case 4: + printf("k = %d", countGreaterThen(10)); + break; + case 5: + timesLastEven(2); + break; + case 6: + printf("k = %d", countEvenLeftOfMin()); + break; + case 7: + timesOddRightOfMin(10); + break; + case 8: + ReplaceMinMax(); + break; + case 9: + allEven(-1); + break; + case 10: + allLess4(); + break; + case 11: + right0(); + break; + case 21: + printf("index: "); + ; + scanf_s("%d", &ind); + deleteElement(ind); + break; + case 22: + printf("index: "); + scanf_s("%d", &ind); + + printf("value: "); + scanf_s("%d", &value); + insertElement(value,ind); + break; + case 23: + deleteElement(getMin().index); + break; + case 24: + insertElement(0, getMin().index); + break; + case 25: + value = arr[0]; + ind = 0; + for (int i = 1; i < lenght; i++) { + if (arr[i] % 2 == 0 && arr[i] > value) { + value = arr[i]; + ind = i; + } + + } + deleteElement(ind); + break; + case 0: + break; + default: + break; + } + } while (ans != 0); +} \ No newline at end of file diff --git a/13-14/Function.h b/13-14/Function.h new file mode 100644 index 0000000..f061f5a --- /dev/null +++ b/13-14/Function.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +#define DEFAULT_LENGHT 10 + +extern int arr[DEFAULT_LENGHT]; + +typedef struct { + int value, index; +} Element; + +void startProg(); \ No newline at end of file diff --git a/13-14/Main.c b/13-14/Main.c new file mode 100644 index 0000000..913310e --- /dev/null +++ b/13-14/Main.c @@ -0,0 +1,12 @@ +#include +#include +#include "Function.h" + +int main() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + + startProg(); + + return 0; +} \ No newline at end of file diff --git a/13-14/desktop.ini b/13-14/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/13-14/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/15/15.vcxproj b/15/15.vcxproj new file mode 100644 index 0000000..1c79105 --- /dev/null +++ b/15/15.vcxproj @@ -0,0 +1,139 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {8cbc5826-531f-45fd-aa76-17dcd4e25d30} + My15 + 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..7d75e84 --- /dev/null +++ b/15/15.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {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/15/Main.c b/15/Main.c new file mode 100644 index 0000000..e418ee4 --- /dev/null +++ b/15/Main.c @@ -0,0 +1,13 @@ +#include +#include + + + +int main() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + + startProg(); + + return 0; +} \ No newline at end of file diff --git a/15/TwoDimentionalArray.c b/15/TwoDimentionalArray.c new file mode 100644 index 0000000..acdaefa --- /dev/null +++ b/15/TwoDimentionalArray.c @@ -0,0 +1,240 @@ +#include "TwoDimentionalArray.h" + +int arr[MAX_LENGTH][MAX_LENGTH]; +int width, height; + +void inputdem() { + printf("height "); + scanf_s("%d", &height); + + printf("width "); + scanf_s("%d", &width); +} + +void randomEl() { + if (width == 0 || height == 0) inputdem(); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + arr[i][j] = rand() % 10 + 1; + } + } +} + +void iX10j() { + if (width == 0 || height == 0) inputdem(); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + arr[i][j] = (i+1)*10+j+1; + } + } +} + +void setZero() { + if (width == 0 || height == 0) inputdem(); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + arr[i][j] = 0; + } + } +} + +void inputArr() { + inputdem(); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + scanf_s("%d", &arr[i][j]); + } + } +} + +void oddX10() { + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + if (arr[i][j] % 2 != 0) { + arr[i][j] = arr[i][j] * 10; + } + } + } +} + +void del10() { + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + if (arr[i][j] % 10 == 0) { + arr[i][j] = arr[i][j] / 10; + } + } + } +} + +void save() { + FILE* fout = fopen("D:\\university\\\\lab\\Temp\\test.txt", "wt"); + + if (fout == NULL) { + printf(" "); + return; + } + + fprintf(fout, "%d ", height); + fprintf(fout, "%d\n", width); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + fprintf(fout, "%d ", arr[i][j]); + } + fprintf(fout, "\n"); + } + + printf("\n"); + + fclose(fout); +} + +void load() { + FILE* fin = fopen("D:\\university\\\\lab\\Temp\\test.txt", "rt"); + + if (fin == NULL) { + printf(" "); + return; + } + + fscanf_s(fin, "%d", &height); + fscanf_s(fin, "%d", &width); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + fscanf_s(fin, "%d", &arr[i][j]); + } + } + + printf("\n"); + + fclose(fin); +} + +void dublicateCol() { + int index; + printf("index "); + scanf_s("%d", &index); + for (int i = width; i > index; i--) { + for (int j = 0; j < height; j++) { + arr[j][i] = arr[j][i - 1]; + } + } + width += 1; +} + +void DeleteRow() { + int index; + printf("index "); + scanf_s("%d", &index); + height -= 1; + for (int i = index; i < height; i++) { + for (int j = 0; j < width; j++) { + arr[i][j] = arr[i + 1][j]; + } + } +} + +void zeroWhereRepeat() { + for (int j = 0; j < width; j++) { + + bool DO = false; + + for (int i = 0; i < height - 1; i++) { + for (int ii = i + 1; ii < height; ii++) { + if (arr[i][j] == arr[ii][j]) { + DO = true; + goto end; + } + } + } + end: + if (DO) { + for (int i = 0; i < height; i++) { + arr[i][j] = 0; + } + } + } + +} + +void printArr() { + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + printf("%3d ", arr[i][j]); + } + printf("\n"); + } +} + +void menuText() { + printf("\n\n"); + if (height != 0) { + printf(": %d\n", height); + printArr(arr, width, height); + } + printf("--------------\n"); + printf(" :\n"); + printf("1) i * 10 + j\n"); + printf("2) 0\n"); + printf("3) \n"); + printf("4) 10\n"); + printf("5) % 10 1del10\n"); + printf("6) \n"); + printf("71) \n"); + printf("72) \n"); + printf("8) 0 \n"); + printf("9) \n"); + printf("10) \n"); + printf("\n"); + printf("-1) \n"); + printf(" >>> "); +} + +void startProg() { + + srand(time(NULL)); + + int ans; + do { + menuText(); + scanf_s("%d", &ans); + + switch (ans) + { + case 1: + iX10j(); + break; + case 2: + setZero(); + break; + case 3: + randomEl(); + break; + case 4: + oddX10(); + break; + case 5: + del10(); + break; + case 6: + inputArr(); + break; + case 71: + save(); + break; + case 72: + load(); + break; + case 8: + zeroWhereRepeat(); + break; + case 9: + dublicateCol(); + break; + case 10: + DeleteRow(); + default: + break; + } + } while (ans != -1); +} \ No newline at end of file diff --git a/15/TwoDimentionalArray.h b/15/TwoDimentionalArray.h new file mode 100644 index 0000000..d277d0e --- /dev/null +++ b/15/TwoDimentionalArray.h @@ -0,0 +1,10 @@ +#pragma once +#include +#include +#include +#include +#include + +#define MAX_LENGTH 10 + +void startProg(); \ No newline at end of file diff --git a/15/desktop.ini b/15/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/15/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/16/16.cpp b/16/16.cpp new file mode 100644 index 0000000..cbc1095 --- /dev/null +++ b/16/16.cpp @@ -0,0 +1,514 @@ +// 16.cpp : Определяет точку входа для приложения. +// + +#include "framework.h" +#include "16.h" +#include + + + +enum Material { + void_m, + player_m, + wall_m, + gold_m +}; + +#define WIDTH_MAP 30 +#define HEIGHT_MAP 20 + +#define WIDTH_1 20 +#define HEIGHT_1 20 + +int map[HEIGHT_MAP][WIDTH_MAP] = { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 0, 0, 3, 0, 0, 0, 0, 0}, + {0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 3, 3, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 3, 3, 0, 0, 0}, + + {0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 2, 0, 0, 2, 0}, + {0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0}, + {0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +}; + +int step = 0, gold = 0; + +POINT getPlayerCoord() { + + for (int i = 0; i < WIDTH_MAP; i++) { + for (int j = 0; j < WIDTH_MAP; j++) { + if (map[i][j] == 1) return { j,i }; + } + } + return { -1,-1 }; +} + +void right() { + POINT c = getPlayerCoord(); + if (c.x < 0 || map[c.y][c.x + 1] == wall_m) return; + + if (map[c.y][c.x + 1] == gold_m) { + gold += 1; + } + + map[c.y][c.x + 1] = 1; + map[c.y][c.x] = void_m; + step++; +} + +void left() { + POINT c = getPlayerCoord(); + if (c.x < 0 || map[c.y][c.x - 1] == wall_m) return; + + if (map[c.y][c.x - 1] == gold_m) { + gold += 1; + } + + map[c.y][c.x - 1] = 1; + map[c.y][c.x] = void_m; + step++; +} + +void down() { + POINT c = getPlayerCoord(); + if (c.x < 0 || map[c.y + 1][c.x] == wall_m) return; + + if (map[c.y + 1][c.x] == gold_m) { + gold += 1; + } + + map[c.y + 1][c.x] = 1; + map[c.y][c.x] = void_m; + step++; +} + +void up() { + POINT c = getPlayerCoord(); + if (c.x < 0 || map[c.y - 1][c.x] == wall_m) return; + + if (map[c.y - 1][c.x] == gold_m) { + gold += 1; + } + + map[c.y - 1][c.x] = 1; + map[c.y][c.x] = void_m; + step++; +} + +void createWall() { + POINT c = getPlayerCoord(); + if (c.x < 0 || c.x - 1 < 0) return; + + map[c.y][c.x - 1] = wall_m; +} + +void dropGold() { + POINT c = getPlayerCoord(); + if (c.x < 0 || c.x + 1 > WIDTH_MAP || map[c.y][c.x + 1] == gold_m || map[c.y][c.x + 1] == wall_m) return; + + if (gold > 0) { + map[c.y][c.x + 1] = gold_m; + gold--; + } +} + +void Z() { + POINT c = getPlayerCoord(); + if (c.x < 0) return; + + for (int i = c.x + 1; i < WIDTH_MAP; i++) { + if (map[c.y][i] == wall_m) map[c.y][i] = void_m; + } +} + +void U() { + POINT c = getPlayerCoord(); + if (c.x < 0) return; + + + for (int i = -2; i < 3; i++) { + if (i == 0 || c.x+i < 0 || c.x + i >= WIDTH_MAP || c.y + i < 0 || c.y - i >= HEIGHT_MAP) continue; + map[c.y + i][c.x + i] = wall_m; + } + + for (int i = -2; i < 3; i++) { + if (i == 0 || c.x + i < 0 || c.x + i >= WIDTH_MAP || c.y - i < 0 || c.y + i >= HEIGHT_MAP) continue; + map[c.y - i][c.x + i] = wall_m; + } +} + +void D() { + POINT c = getPlayerCoord(); + if (c.x < 0) return; + + + for (int i = -2; i < 3; i++) { + if (gold <= 0) break; + if (i == 0 || c.x + i < 0 || c.x + i >= WIDTH_MAP || c.y + i < 0 || c.y - i >= HEIGHT_MAP) continue; + if (map[c.y + i][c.x + i] == wall_m) continue; + map[c.y + i][c.x + i] = gold_m; + gold--; + } + + for (int i = -2; i < 3; i++) { + if (gold <= 0) break; + if (i == 0 || c.x + i < 0 || c.x + i >= WIDTH_MAP || c.y - i < 0 || c.y + i >= HEIGHT_MAP) continue; + if (map[c.y - i][c.x + i] == wall_m) continue; + map[c.y - i][c.x + i] = gold_m; + gold--; + } +} + +void save() { + FILE* fout; + fopen_s(&fout, "D:\\university\\ОАИП\\lab\\Temp\\game.bin", "wb"); + if (fout == NULL) { + printf(""); + return; + } + int width = WIDTH_MAP, height = HEIGHT_MAP; + + fwrite(&width, sizeof(width), 1, fout); + fwrite(&height, sizeof(height), 1, fout); + fwrite(&map, sizeof(map), 1, fout); + fwrite(&step, sizeof(step), 1, fout); + fwrite(&gold, sizeof(gold), 1, fout); + fclose(fout); +} + +void load() { + FILE* fin; + fopen_s(&fin, "D:\\university\\ОАИП\\lab\\Temp\\game.bin", "rb"); + if (fin == NULL) { + printf(""); + return; + } + int width, height; + + fread(&width, sizeof(width), 1, fin); + fread(&height, sizeof(height), 1, fin); + fread(&map, sizeof(map), 1, fin); + fread(&step, sizeof(step), 1, fin); + fread(&gold, sizeof(gold), 1, fin); + fclose(fin); +} + +void restartGame() { + FILE* fin; + fopen_s(&fin, "D:\\university\\ОАИП\\lab\\Temp\\start.bin", "rb"); + if (fin == NULL) { + printf(""); + return; + } + int width, height; + + fread(&width, sizeof(width), 1, fin); + fread(&height, sizeof(height), 1, fin); + fread(&map, sizeof(map), 1, fin); + fread(&step, sizeof(step), 1, fin); + fread(&gold, sizeof(gold), 1, fin); + fclose(fin); +} + +void drawMap(HDC hdc) { + HBRUSH materials[4] = { + (HBRUSH)CreateSolidBrush(RGB(127,127,127)), + (HBRUSH)CreateSolidBrush(RGB(0,0,255)), + (HBRUSH)CreateSolidBrush(RGB(0,0,0)), + (HBRUSH)CreateSolidBrush(RGB(255,255,0)) + }; + + for (int i = 0; i < HEIGHT_MAP; i++) { + for (int j = 0; j < WIDTH_MAP; j++) { + RECT r = { j * WIDTH_1, i * HEIGHT_1, (j + 1) * WIDTH_1, (i + 1) * HEIGHT_1 }; + FillRect(hdc, &r, materials[map[i][j]]); + } + } + + char text[80]; + sprintf_s(text, "steps = %d, gold = %d", step, gold); + TextOutA(hdc, 10, HEIGHT_MAP * HEIGHT_1, (LPCSTR)text, strlen(text)); + + for (int i = 0; i < 4; i++) DeleteObject(materials[i]); +} + +void Midas(int i, int j) { + if (map[i][j] == 2) { + map[i][j] = 3; + if (i > 0) Midas(i - 1, j); + if (i < HEIGHT_MAP - 1) Midas(i + 1, j); + if (j > 0) Midas(i, j - 1); + if (i < WIDTH_MAP) Midas(i, j + 1); + } +} + +void M() { + POINT c = getPlayerCoord(); + Midas(c.y, c.x + 1); +} + + + + + + + + + + + + + + + + + + + + + +#define MAX_LOADSTRING 100 + +// Глобальные переменные: +HINSTANCE hInst; // текущий экземпляр +WCHAR szTitle[MAX_LOADSTRING]; // Текст строки заголовка +WCHAR szWindowClass[MAX_LOADSTRING]; // имя класса главного окна + +// Отправить объявления функций, включенных в этот модуль кода: +ATOM MyRegisterClass(HINSTANCE hInstance); +BOOL InitInstance(HINSTANCE, int); +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); + +int APIENTRY wWinMain(_In_ HINSTANCE hInstance, + _In_opt_ HINSTANCE hPrevInstance, + _In_ LPWSTR lpCmdLine, + _In_ int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + + // TODO: Разместите код здесь. + + // Инициализация глобальных строк + LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + LoadStringW(hInstance, IDC_MY16, szWindowClass, MAX_LOADSTRING); + MyRegisterClass(hInstance); + + // Выполнить инициализацию приложения: + if (!InitInstance (hInstance, nCmdShow)) + { + return FALSE; + } + + HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MY16)); + + MSG msg; + + // Цикл основного сообщения: + while (GetMessage(&msg, nullptr, 0, 0)) + { + if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + return (int) msg.wParam; +} + +// +// ФУНКЦИЯ: MyRegisterClass() +// +// ЦЕЛЬ: Регистрирует класс окна. +// +ATOM MyRegisterClass(HINSTANCE hInstance) +{ + WNDCLASSEXW wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MY16)); + wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_MY16); + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); + + return RegisterClassExW(&wcex); +} + +// +// ФУНКЦИЯ: InitInstance(HINSTANCE, int) +// +// ЦЕЛЬ: Сохраняет маркер экземпляра и создает главное окно +// +// КОММЕНТАРИИ: +// +// В этой функции маркер экземпляра сохраняется в глобальной переменной, а также +// создается и выводится главное окно программы. +// +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + hInst = hInstance; // Сохранить маркер экземпляра в глобальной переменной + + HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr); + + if (!hWnd) + { + return FALSE; + } + + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + return TRUE; +} + +// +// ФУНКЦИЯ: WndProc(HWND, UINT, WPARAM, LPARAM) +// +// ЦЕЛЬ: Обрабатывает сообщения в главном окне. +// +// WM_COMMAND - обработать меню приложения +// WM_PAINT - Отрисовка главного окна +// WM_DESTROY - отправить сообщение о выходе и вернуться +// +// +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_COMMAND: + { + int wmId = LOWORD(wParam); + // Разобрать выбор в меню: + switch (wmId) + { + case IDM_ABOUT: + DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); + break; + case ISave: + save(); + break; + case ILoad: + load(); + InvalidateRect(hWnd, NULL, TRUE); + break; + case IDM_EXIT: + DestroyWindow(hWnd); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + } + break; + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdc = BeginPaint(hWnd, &ps); + // TODO: Добавьте сюда любой код прорисовки, использующий HDC... + + drawMap(hdc); + + EndPaint(hWnd, &ps); + } + break; + case WM_CHAR: + switch (wParam) { + case 'l': + createWall(); + InvalidateRect(hWnd, NULL, TRUE); + break; + case 'r': + dropGold(); + InvalidateRect(hWnd, NULL, TRUE); + break; + case 'z': + Z(); + InvalidateRect(hWnd, NULL, TRUE); + break; + case 'u': + U(); + InvalidateRect(hWnd, NULL, TRUE); + break; + case 'd': + D(); + InvalidateRect(hWnd, NULL, TRUE); + break; + case 'm': + M(); + InvalidateRect(hWnd, NULL, TRUE); + break; + } + break; + case WM_KEYDOWN: + switch (wParam) + { + case VK_RIGHT: + right(); + InvalidateRect(hWnd, NULL, TRUE); + break; + case VK_LEFT: + left(); + InvalidateRect(hWnd, NULL, TRUE); + break; + case VK_UP: + up(); + InvalidateRect(hWnd, NULL, TRUE); + break; + case VK_DOWN: + down(); + InvalidateRect(hWnd, NULL, TRUE); + break; + case VK_F5: + save(); + break; + case VK_F9: + load(); + InvalidateRect(hWnd, NULL, TRUE); + break; + case VK_F6: + restartGame(); + InvalidateRect(hWnd, NULL, TRUE); + break; + } + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} + +// Обработчик сообщений для окна "О программе". +INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + UNREFERENCED_PARAMETER(lParam); + switch (message) + { + case WM_INITDIALOG: + return (INT_PTR)TRUE; + + case WM_COMMAND: + if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) + { + EndDialog(hDlg, LOWORD(wParam)); + return (INT_PTR)TRUE; + } + break; + } + return (INT_PTR)FALSE; +} diff --git a/16/16.h b/16/16.h new file mode 100644 index 0000000..b798bf5 --- /dev/null +++ b/16/16.h @@ -0,0 +1,3 @@ +#pragma once + +#include "resource.h" diff --git a/16/16.ico b/16/16.ico new file mode 100644 index 0000000..b3ec03b Binary files /dev/null and b/16/16.ico differ diff --git a/16/16.rc b/16/16.rc new file mode 100644 index 0000000..cd85ca3 Binary files /dev/null and b/16/16.rc differ diff --git a/16/16.vcxproj b/16/16.vcxproj new file mode 100644 index 0000000..30c4aef --- /dev/null +++ b/16/16.vcxproj @@ -0,0 +1,148 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {ca6a78f7-f0cf-443e-a713-347385883516} + My16 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Level3 + true + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/16/16.vcxproj.filters b/16/16.vcxproj.filters new file mode 100644 index 0000000..b2a7c4b --- /dev/null +++ b/16/16.vcxproj.filters @@ -0,0 +1,49 @@ + + + + + {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/16/desktop.ini b/16/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/16/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/16/framework.h b/16/framework.h new file mode 100644 index 0000000..a8f6dc8 --- /dev/null +++ b/16/framework.h @@ -0,0 +1,15 @@ +// header.h: включаемый файл для стандартных системных включаемых файлов +// или включаемые файлы для конкретного проекта +// + +#pragma once + +#include "targetver.h" +#define WIN32_LEAN_AND_MEAN // Исключите редко используемые компоненты из заголовков Windows +// Файлы заголовков Windows +#include +// Файлы заголовков среды выполнения C +#include +#include +#include +#include diff --git a/16/resource.h b/16/resource.h new file mode 100644 index 0000000..f4ed070 --- /dev/null +++ b/16/resource.h @@ -0,0 +1,31 @@ +//{{NO_DEPENDENCIES}} +// Включаемый файл, созданный в Microsoft Visual C++. +// Используется 16.rc +// +#define IDC_MYICON 2 +#define IDD_MY16_DIALOG 102 +#define IDS_APP_TITLE 103 +#define IDD_ABOUTBOX 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDI_MY16 107 +#define IDI_SMALL 108 +#define IDC_MY16 109 +#define IDR_MAINFRAME 128 +#define ID_32771 32771 +#define ID_32772 32772 +#define ILoad 32773 +#define ISave 32774 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32775 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/16/small.ico b/16/small.ico new file mode 100644 index 0000000..b3ec03b Binary files /dev/null and b/16/small.ico differ diff --git a/16/targetver.h b/16/targetver.h new file mode 100644 index 0000000..d90003d --- /dev/null +++ b/16/targetver.h @@ -0,0 +1,6 @@ +#pragma once + +// // При включении SDKDDKVer.h будет задана самая новая из доступных платформ Windows. +// Если вы планируете сборку приложения для предыдущей версии платформы Windows, включите WinSDKVer.h и +// задайте желаемую платформу в макросе _WIN32_WINNT, прежде чем включать SDKDDKVer.h. +#include diff --git a/17/17.c b/17/17.c new file mode 100644 index 0000000..5ef070a --- /dev/null +++ b/17/17.c @@ -0,0 +1,112 @@ +#include + +int fact(int); +void f1(int), f2(int), f3(int); +void recEGE1(int); +void Z5(int); +void Z6(int); +void Z7G(int), Z7F(int); +void Z9V8(int); + +int main() { + printf("%d", fact(5)); + + printf("\n"); + + f1(11); + printf("\n"); + f2(11); + printf("\n"); + f3(11); + + printf("\n"); + + recEGE1(3); + + printf("\n\n"); + + Z5(10); + + printf("\n\n"); + + Z6(1); + + printf("\n\n"); + + Z7F(11); + + printf("\n\n"); + + Z9V8(5); + return 0; +} + +int fact(int a) { + if (a < 0) return -1; + if (a == 0) return 1; + return fact(a - 1) * a; +} + +void f1(int a) { + if (a < 0) return; + printf("%d ", a); + if (a >= 2) f1(a - 2); +} + +void f2(int a) { + if (a < 0) return; + if (a >= 2) f2(a - 2); + printf("%d ", a); +} + +void f3(int a) { + if (a < 0) return; + if (a < 2) { + printf("%d ", a); + return; + } + printf("%d ", a); + if (a >= 2) f3(a - 2); + printf("%d ", a); +} + +void recEGE1(int n) { + if (n >= 1) { + printf("%d ", n); + recEGE1(n - 1); + recEGE1(n - 1); + } +} + + +void Z5(int n) { + if (n >= 1) { + printf("%d\n", n); + Z5(n - 3); + Z5(n - 4); + } +} + +void Z6(int n) { + if (n < 5) { + printf("%d\n", n); + Z5(n + 1); + Z5(n + 3); + } +} + +void Z7F(int a) { + if (a > 0) Z7G(a - 1); +}; + +void Z7G(int a) { + printf("*"); + if (a > 1) Z7F(a - 3); +}; + +void Z9V8(int a) { + if (a < 0) return; + printf("<*%d*", a); + if (a > 1) Z9V8(a - 1); + printf("%d>", a); +} \ No newline at end of file diff --git a/17/17.vcxproj b/17/17.vcxproj new file mode 100644 index 0000000..63d5667 --- /dev/null +++ b/17/17.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {85e1e279-bfca-48f2-ad89-22f8b3934ca4} + My17 + 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/17/17.vcxproj.filters b/17/17.vcxproj.filters new file mode 100644 index 0000000..de798d5 --- /dev/null +++ b/17/17.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/17/desktop.ini b/17/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/17/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/18/18.cpp b/18/18.cpp new file mode 100644 index 0000000..091202d --- /dev/null +++ b/18/18.cpp @@ -0,0 +1,448 @@ +// 18.cpp : Определяет точку входа для приложения. +// + +#include "framework.h" +#include "stdio.h" +#include "18.h" + +#define MAX_LOADSTRING 100 + +int count = 0; +int Action = 0; + + + + + + + +void triangle(HDC hdc, int cx, int cy, int size) { + SelectObject(hdc, GetStockObject(NULL_BRUSH)); + POINT pt[3] = { + {cx,cy + size}, + {cx + size,cy - size}, + {cx - size,cy - size} + }; + Polygon(hdc, pt, 3); + SelectObject(hdc, GetStockObject(DC_BRUSH)); +} + +void triangleFact1(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + triangle(hdc, cx, cy, size); + triangleFact1(hdc, cx - size, cy - size, size / 2); + triangleFact1(hdc, cx, cy + size, size / 2); +} + +void triangleFact2(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + triangle(hdc, cx, cy, size); + triangleFact2(hdc, cx - size, cy - size, size / 2); + triangleFact2(hdc, cx + size, cy - size, size / 2); +} + +void triangleFact3(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + triangle(hdc, cx, cy, size); + triangleFact3(hdc, cx - size, cy - size, size / 2); + triangleFact3(hdc, cx + size, cy - size, size / 2); + triangleFact3(hdc, cx, cy + size, size / 2); +} + +void time(HDC hdc, int cx, int cy, int size) { + SelectObject(hdc, GetStockObject(NULL_BRUSH)); + POINT pt[4] = { + {cx + size,cy + size}, + {cx - size,cy + size}, + {cx + size / 2,cy - size}, + {cx - size / 2,cy - size}, + }; + Polygon(hdc, pt, 4); + SelectObject(hdc, GetStockObject(DC_BRUSH)); +} + +void timeFact1(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + time(hdc, cx, cy, size); + timeFact1(hdc, cx - size / 2 , cy - size, size / 2); +} + +void timeFact2(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + time(hdc, cx, cy, size); + timeFact2(hdc, cx - size / 2, cy - size, size / 2); + timeFact2(hdc, cx + size / 2, cy - size, size / 2); +} + +void timeFact3(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + time(hdc, cx, cy, size); + timeFact3(hdc, cx - size / 2, cy - size, size / 2); + timeFact3(hdc, cx - size, cy + size, size / 2); + timeFact3(hdc, cx + size / 2, cy - size, size / 2); + timeFact3(hdc, cx + size, cy + size, size / 2); +} + +void dimond(HDC hdc, int cx, int cy, int size) { + SelectObject(hdc, GetStockObject(NULL_BRUSH)); + POINT pt[4] = { + {cx,cy - size}, + {cx + size,cy}, + {cx,cy + size}, + {cx - size,cy}, + }; + Polygon(hdc, pt, 4); + SelectObject(hdc, GetStockObject(DC_BRUSH)); +} + +void dimondFact1(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + dimond(hdc, cx, cy, size); + dimondFact1(hdc, cx - size, cy, size / 2); + dimondFact1(hdc, cx + size, cy, size / 2); +} + +void dimondFact2(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + dimond(hdc, cx, cy, size); + dimondFact2(hdc, cx - size, cy, size / 2); + dimondFact2(hdc, cx + size, cy, size / 2); + dimondFact2(hdc, cx, cy + size, size / 2); +} + +void dimondFact3(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + dimond(hdc, cx, cy, size); + dimondFact2(hdc, cx - size, cy, size / 2); + dimondFact2(hdc, cx + size, cy, size / 2); + dimondFact2(hdc, cx, cy - size, size / 2); +} + +void dimondFact4(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + dimond(hdc, cx, cy, size); + dimondFact3(hdc, cx - size, cy, size / 2); + dimondFact3(hdc, cx + size, cy, size / 2); + dimondFact3(hdc, cx, cy + size, size / 2); + dimondFact3(hdc, cx, cy - size, size / 2); +} + +void star(HDC hdc, int cx, int cy, int size) { + SelectObject(hdc, GetStockObject(NULL_BRUSH)); + POINT pt[8] = { + {cx,cy - size}, + {cx + size / 4,cy - size / 4}, + {cx + size,cy}, + {cx + size / 4,cy + size / 4}, + {cx,cy + size}, + {cx - size / 4,cy + size / 4}, + {cx - size,cy}, + {cx - size / 4,cy - size / 4}, + }; + Polygon(hdc, pt, 8); + SelectObject(hdc, GetStockObject(DC_BRUSH)); +} + +void starFact1(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + star(hdc, cx, cy, size); + starFact1(hdc, cx - size, cy, size / 2); + starFact1(hdc, cx + size, cy, size / 2); +} + +void starFact2(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + star(hdc, cx, cy, size); + starFact2(hdc, cx, cy - size, size / 2); + starFact2(hdc, cx, cy + size, size / 2); +} + +void starFact3(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + star(hdc, cx, cy, size); + starFact3(hdc, cx, cy - size, size / 2); + starFact3(hdc, cx, cy + size, size / 2); + starFact3(hdc, cx - size, cy, size / 2); +} + +void arrow(HDC hdc, int cx, int cy, int size) { + SelectObject(hdc, GetStockObject(NULL_BRUSH)); + POINT pt[7] = { + {cx - size / 2,cy - size}, + {cx + size / 2,cy - size}, + {cx + size / 2,cy}, + {cx + size,cy}, + {cx,cy + size}, + {cx - size,cy}, + {cx - size / 2,cy}, + }; + Polygon(hdc, pt, 7); + SelectObject(hdc, GetStockObject(DC_BRUSH)); +} + +void arrowFactMini(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + arrow(hdc, cx, cy, size); + + count++; + char text[80]; + sprintf_s(text, "%d", count); + TextOutA(hdc, cx, cy, (LPCSTR)text, strlen(text)); + + arrowFactMini(hdc, cx - size / 2, cy - size, size / 2); + arrowFactMini(hdc, cx + size / 2, cy - size, size / 2); + arrowFactMini(hdc, cx + size, cy, size / 2); + arrowFactMini(hdc, cx, cy + size, size / 2); + arrowFactMini(hdc, cx - size, cy, size / 2); +} + +void arrowFactMaxi(HDC hdc, int cx, int cy, int size) { + if (size <= 10) return; + arrow(hdc, cx, cy, size); + + count++; + char text[80]; + sprintf_s(text, "%d", count); + TextOutA(hdc, cx, cy, (LPCSTR)text, strlen(text)); + + arrowFactMaxi(hdc, cx - size / 2, cy - size, size / 3); + arrowFactMaxi(hdc, cx + size / 2, cy - size, size / 3); + arrowFactMaxi(hdc, cx + size, cy, size / 3); + arrowFactMaxi(hdc, cx, cy + size, size / 3); + arrowFactMaxi(hdc, cx - size, cy, size / 3); +} + + + + + + + + + +// Глобальные переменные: +HINSTANCE hInst; // текущий экземпляр +WCHAR szTitle[MAX_LOADSTRING]; // Текст строки заголовка +WCHAR szWindowClass[MAX_LOADSTRING]; // имя класса главного окна + +// Отправить объявления функций, включенных в этот модуль кода: +ATOM MyRegisterClass(HINSTANCE hInstance); +BOOL InitInstance(HINSTANCE, int); +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); + +int APIENTRY wWinMain(_In_ HINSTANCE hInstance, + _In_opt_ HINSTANCE hPrevInstance, + _In_ LPWSTR lpCmdLine, + _In_ int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + + // TODO: Разместите код здесь. + + // Инициализация глобальных строк + LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + LoadStringW(hInstance, IDC_MY18, szWindowClass, MAX_LOADSTRING); + MyRegisterClass(hInstance); + + // Выполнить инициализацию приложения: + if (!InitInstance (hInstance, nCmdShow)) + { + return FALSE; + } + + HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MY18)); + + MSG msg; + + // Цикл основного сообщения: + while (GetMessage(&msg, nullptr, 0, 0)) + { + if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + return (int) msg.wParam; +} + + + +// +// ФУНКЦИЯ: MyRegisterClass() +// +// ЦЕЛЬ: Регистрирует класс окна. +// +ATOM MyRegisterClass(HINSTANCE hInstance) +{ + WNDCLASSEXW wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MY18)); + wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_MY18); + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); + + return RegisterClassExW(&wcex); +} + +// +// ФУНКЦИЯ: InitInstance(HINSTANCE, int) +// +// ЦЕЛЬ: Сохраняет маркер экземпляра и создает главное окно +// +// КОММЕНТАРИИ: +// +// В этой функции маркер экземпляра сохраняется в глобальной переменной, а также +// создается и выводится главное окно программы. +// +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + hInst = hInstance; // Сохранить маркер экземпляра в глобальной переменной + + HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr); + + if (!hWnd) + { + return FALSE; + } + + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + return TRUE; +} + +// +// ФУНКЦИЯ: WndProc(HWND, UINT, WPARAM, LPARAM) +// +// ЦЕЛЬ: Обрабатывает сообщения в главном окне. +// +// WM_COMMAND - обработать меню приложения +// WM_PAINT - Отрисовка главного окна +// WM_DESTROY - отправить сообщение о выходе и вернуться +// +// +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_COMMAND: + { + int wmId = LOWORD(wParam); + // Разобрать выбор в меню: + switch (wmId) + { + case IDM_ABOUT: + DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); + break; + case IDM_EXIT: + DestroyWindow(hWnd); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + } + break; + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdc = BeginPaint(hWnd, &ps); + + count = 0; + + switch (Action % 15) { + case 0: + triangleFact1(hdc, 200, 200, 100); + break; + case 1: + triangleFact2(hdc, 200, 200, 100); + break; + case 2: + triangleFact3(hdc, 200, 200, 100); + break; + case 3: + timeFact1(hdc, 200, 200, 100); + break; + case 4: + timeFact2(hdc, 200, 200, 100); + break; + case 5: + timeFact3(hdc, 200, 200, 100); + break; + case 6: + dimondFact1(hdc, 200, 200, 100); + break; + case 7: + dimondFact2(hdc, 200, 200, 100); + break; + case 8: + dimondFact3(hdc, 200, 200, 100); + break; + case 9: + dimondFact4(hdc, 200, 200, 100); + break; + case 10: + starFact1(hdc, 200, 200, 100); + break; + case 11: + starFact2(hdc, 200, 200, 100); + break; + case 12: + starFact3(hdc, 200, 200, 100); + break; + case 13: + arrowFactMini(hdc, 200, 200, 100); + break; + case 14: + arrowFactMaxi(hdc, 200, 200, 100); + break; + } + + EndPaint(hWnd, &ps); + } + break; + case WM_KEYDOWN: + Action ++; + InvalidateRect(hWnd, NULL, TRUE); + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} + +// Обработчик сообщений для окна "О программе". +INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + UNREFERENCED_PARAMETER(lParam); + switch (message) + { + case WM_INITDIALOG: + return (INT_PTR)TRUE; + + case WM_COMMAND: + if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) + { + EndDialog(hDlg, LOWORD(wParam)); + return (INT_PTR)TRUE; + } + break; + } + return (INT_PTR)FALSE; +} diff --git a/18/18.h b/18/18.h new file mode 100644 index 0000000..b798bf5 --- /dev/null +++ b/18/18.h @@ -0,0 +1,3 @@ +#pragma once + +#include "resource.h" diff --git a/18/18.ico b/18/18.ico new file mode 100644 index 0000000..b3ec03b Binary files /dev/null and b/18/18.ico differ diff --git a/18/18.rc b/18/18.rc new file mode 100644 index 0000000..ffcbb2b Binary files /dev/null and b/18/18.rc differ diff --git a/18/18.vcxproj b/18/18.vcxproj new file mode 100644 index 0000000..23ef448 --- /dev/null +++ b/18/18.vcxproj @@ -0,0 +1,148 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {4839da26-feba-494b-aa4a-af4a46c6ba51} + My18 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Level3 + true + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/18/18.vcxproj.filters b/18/18.vcxproj.filters new file mode 100644 index 0000000..dc147e1 --- /dev/null +++ b/18/18.vcxproj.filters @@ -0,0 +1,49 @@ + + + + + {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/18/Resource.h b/18/Resource.h new file mode 100644 index 0000000..1c650fd --- /dev/null +++ b/18/Resource.h @@ -0,0 +1,30 @@ +//{{NO_DEPENDENCIES}} +// Включаемый файл, созданный в Microsoft Visual C++. +// Используется 18.rc + +#define IDS_APP_TITLE 103 + +#define IDR_MAINFRAME 128 +#define IDD_MY18_DIALOG 102 +#define IDD_ABOUTBOX 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDI_MY18 107 +#define IDI_SMALL 108 +#define IDC_MY18 109 +#define IDC_MYICON 2 +#ifndef IDC_STATIC +#define IDC_STATIC -1 +#endif +// Следующие стандартные значения для новых объектов +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS + +#define _APS_NO_MFC 130 +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/18/desktop.ini b/18/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/18/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/18/framework.h b/18/framework.h new file mode 100644 index 0000000..a8f6dc8 --- /dev/null +++ b/18/framework.h @@ -0,0 +1,15 @@ +// header.h: включаемый файл для стандартных системных включаемых файлов +// или включаемые файлы для конкретного проекта +// + +#pragma once + +#include "targetver.h" +#define WIN32_LEAN_AND_MEAN // Исключите редко используемые компоненты из заголовков Windows +// Файлы заголовков Windows +#include +// Файлы заголовков среды выполнения C +#include +#include +#include +#include diff --git a/18/small.ico b/18/small.ico new file mode 100644 index 0000000..b3ec03b Binary files /dev/null and b/18/small.ico differ diff --git a/18/targetver.h b/18/targetver.h new file mode 100644 index 0000000..d90003d --- /dev/null +++ b/18/targetver.h @@ -0,0 +1,6 @@ +#pragma once + +// // При включении SDKDDKVer.h будет задана самая новая из доступных платформ Windows. +// Если вы планируете сборку приложения для предыдущей версии платформы Windows, включите WinSDKVer.h и +// задайте желаемую платформу в макросе _WIN32_WINNT, прежде чем включать SDKDDKVer.h. +#include diff --git a/19-20/19-20.vcxproj b/19-20/19-20.vcxproj new file mode 100644 index 0000000..dfba300 --- /dev/null +++ b/19-20/19-20.vcxproj @@ -0,0 +1,136 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {969ad85f-9a3b-4a45-b60c-147307ec5453} + My1920 + 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/19-20/19-20.vcxproj.filters b/19-20/19-20.vcxproj.filters new file mode 100644 index 0000000..f6710ba --- /dev/null +++ b/19-20/19-20.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {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/19-20/19.c b/19-20/19.c new file mode 100644 index 0000000..1118d14 --- /dev/null +++ b/19-20/19.c @@ -0,0 +1,204 @@ +#include +#include + +void srar(), Load(); +void Psrar(), PLoad(int); +void Psrar3(); +void Z4(); + +int arr[1000]; +int* parr; +int n; + +int main1() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + + Load(); + srar(); + + PLoad(0); + Psrar(); + free(parr); + + PLoad(1); + Psrar3(); + free(parr); + + PLoad(2); + Z4(); + free(parr); + + return 0; +} + +void Load() { + FILE* fin = fopen("D:\\university\\\\lab\\Temp\\19-20\\in1.txt", "rt"); + if (fin == NULL) { + printf(" \n"); + return; + } + + fscanf_s(fin, "%d", &n); + for (int i = 0; i < n; i++) { + fscanf_s(fin, "%d", &arr[i]); + } + + fclose(fin); +} + +void srar() { + float sa = 0; + float s = 0; + for (int i = 0; i < n; i++) { + s += arr[i]; + } + sa = s / n; + + + int m = 0; + for (int i = 0; i < n; i++) { + if (arr[i] > sa) { + m++; + } + } + + FILE* fout = fopen("D:\\university\\\\lab\\Temp\\19-20\\out\\out1.txt", "wt"); + if (fout == NULL) { + printf(" \n"); + return; + } + + fprintf(fout, "%d\n", m); + for (int i = 0; i < n; i++) { + if (arr[i] > sa) { + fprintf(fout, "%d ", arr[i]); + } + } + + fclose(fout); +} + +void PLoad(int action) { + FILE* fin = NULL; + if (action == 0) { + fopen_s(&fin, "D:\\university\\\\lab\\Temp\\19-20\\in2.txt", "rt"); + } + else if (action == 1) { + fopen_s(&fin, "D:\\university\\\\lab\\Temp\\19-20\\in3.txt", "rt"); + } + else if (action == 2) { + fopen_s(&fin, "D:\\university\\\\lab\\Temp\\19-20\\in4.txt", "rt"); + } + + if (fin == NULL) { + printf(" \n"); + return; + } + + fscanf_s(fin, "%d", &n); + parr = (int*)malloc(sizeof(int) * n); + + for (int i = 0; i < n; i++) { + fscanf_s(fin, "%d", &parr[i]); + } + + fclose(fin); +} + +void Psrar() { + float sa = 0; + float s = 0; + for (int i = 0; i < n; i++) { + s += parr[i]; + } + sa = s / n; + + int m = 0; + for (int i = 0; i < n; i++) { + if (parr[i] > sa) { + m++; + } + } + + FILE* fout = fopen("D:\\university\\\\lab\\Temp\\19-20\\out\\out2.txt", "wt"); + if (fout == NULL) { + printf(" \n"); + return; + } + + fprintf(fout, "%d\n", m); + for (int i = 0; i < n; i++) { + if (parr[i] > sa) { + fprintf(fout, "%d ", parr[i]); + } + } + + fclose(fout); +} + +void Psrar3() { + float sa = 0; + float s = 0; + for (int i = 0; i < n; i++) { + s += parr[i]; + } + sa = s / n; + + int m = 0; + for (int i = 0; i < n; i++) { + if (parr[i] < sa && parr[i] > 0) { + m++; + } + } + + FILE* fout = fopen("D:\\university\\\\lab\\Temp\\19-20\\out\\out3.txt", "wt"); + if (fout == NULL) { + printf(" \n"); + return; + } + + fprintf(fout, "%d\n", m); + for (int i = 0; i < n; i++) { + if (parr[i] < sa && parr[i] > 0) { + fprintf(fout, "%d ", parr[i]); + } + } + + fclose(fout); +} + +void Z4() { + float max = parr[0]; + for (int i = 1; i < n; i++) { + if (parr[i] > max) { + max = parr[i]; + } + } + + float more_then = max*2/3; + + int k = 0; + + for (int i = 0; i < n; i++) { + if (parr[i] >= more_then) { + k++; + } + } + + + FILE* fout = fopen("D:\\university\\\\lab\\Temp\\19-20\\out\\out4.txt", "wt"); + if (fout == NULL) { + printf(" \n"); + return; + } + + fprintf(fout, "%d\n", k); + for (int i = 0; i < n; i++) { + if (parr[i] >= more_then) { + fprintf(fout, "%d ", parr[i]); + } + } + + fclose(fout); +} \ No newline at end of file diff --git a/19-20/20.c b/19-20/20.c new file mode 100644 index 0000000..abfa538 --- /dev/null +++ b/19-20/20.c @@ -0,0 +1,169 @@ +#include +#include + +void printList(), clearList(), addToHead(int); +int deleteFromHead(), contains(int); + +void oddX10(), iX100(int), lessiX10(int); + + +typedef struct NODE { + int data; + struct NODE* next; +} Node; + +Node* arr = NULL; + +int main() { + arr = NULL; + printList(); + + addToHead(1); + printList(); + + addToHead(2); + printList(); + + addToHead(3); + printList(); + + addToHead(4); + addToHead(5); + printList(); + + printf("DELETE\n"); + deleteFromHead(); + printList(); + + int ans = 0; + + scanf_s("%d", &ans); + printf("contains %d %d\n\n", ans, contains(ans)); + + printf("summ = %d\n\n", sum()); + + printf("k%%2==0 = %d\n\n", evenCount()); + + printf("ODD X 10\n"); + oddX10(); + printList(); + + scanf_s("%d", &ans); + printf("a[%d] X 100\n", ans); + iX100(ans); + printList(); + + scanf_s("%d", &ans); + printf("less a[%d] X 10\n", ans); + lessiX10(ans); + printList(); + + clearList(); + printList(); +} + +void printList() { + Node* ptr = arr; + while (ptr != NULL) { + printf("(%d) -> ", ptr->data); + ptr = ptr->next; + } + printf("NULL\n\n"); +} + +void addToHead(int value) { + Node* newNode = (struct Node*)malloc(sizeof(Node)); + + newNode->next = arr; + newNode->data = value; + + arr = newNode; +} + +int deleteFromHead() { + int value = arr->data; + Node* delNode = arr; + arr = arr->next; + free(delNode); + return value; +} + +int contains(int value) { + Node* ptr = arr; + while (ptr != NULL) { + if (ptr->data == value) { + return 1; + } + ptr = ptr->next; + } + return 0; +} + +void clearList() { + while (arr != NULL) + { + Node* delNode = arr; + arr = arr->next; + free(delNode); + } +} + +int sum() { + Node* ptr = arr; + int s = 0; + while (ptr != NULL) { + s += ptr->data; + ptr = ptr->next; + } + return s; +} + +int evenCount() { + Node* ptr = arr; + int k = 0; + while (ptr != NULL) { + if (ptr->data % 2 == 0) { + k++; + } + ptr = ptr->next; + } + return k; +} + +void oddX10() { + Node* ptr = arr; + while (ptr != NULL) { + if (ptr->data % 2 != 0) { + ptr->data *= 10; + } + ptr = ptr->next; + } +} + +void iX100(int i) { + Node* ptr = arr; + int index = 0; + while (ptr != NULL) { + if (index == i) { + ptr->data *= 100; + return; + } + index += 1; + ptr = ptr->next; + } +} + +void lessiX10(int i) { + Node* ptr = arr; + int index = 0; + while (ptr != NULL) { + if (index < i) { + ptr->data = ptr->data * 10; + } + if (index == i) { + return; + } + index += 1; + ptr = ptr->next; + } +} \ No newline at end of file diff --git a/19-20/desktop.ini b/19-20/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/19-20/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/21-22/21-22.vcxproj b/21-22/21-22.vcxproj new file mode 100644 index 0000000..0a65565 --- /dev/null +++ b/21-22/21-22.vcxproj @@ -0,0 +1,136 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {5fa1270b-cd23-45e0-85b8-08b50975c2b9} + My2122 + 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/21-22/21-22.vcxproj.filters b/21-22/21-22.vcxproj.filters new file mode 100644 index 0000000..aa9ee58 --- /dev/null +++ b/21-22/21-22.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {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/21-22/21.c b/21-22/21.c new file mode 100644 index 0000000..84c1a20 --- /dev/null +++ b/21-22/21.c @@ -0,0 +1,110 @@ +#include "stdio.h" +#include "Windows.h" + +int isDigit(char); +char toUpperCase(char); + +int main1() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + + printf(" : "); + + char ch = ' '; + scanf_s("%c", &ch); + + + + printf(" 1\n"); + + for (int i = ch; i <= ch + 19; i++) { + printf("%c, %d\n", i, i); + } + + printf("\n 2\n"); + + for (int i = ch; i >= ch - 29; i--) { + printf("%c, %d\n", i, i); + } + + + + printf("\n 3\n"); + + char str[100]; + int k = 0; + scanf_s(" %[^\n]", &str, 100); + + printf("%s\n", str); + + for (int i = 0; i < strlen(str); i++) + if (str[i] == ' ') k++; + + printf(" = %d\n", k); + + + + printf("\n 4\n"); + + scanf_s(" %[^\n]", &str, 100); + + printf("%s\n", str); + + for (int i = 0; i < strlen(str); i++) + if (str[i] == ' ') str[i] = '#'; + + printf("%s\n", str); + + + + printf("\n 5\n"); + + scanf_s(" %[^\n]", &str, 100); + + printf("%s\n", str); + + for (int i = 0; i < strlen(str); i++) + if (isDigit(str[i])) str[i] = '$'; + + printf("%s\n", str); + + + + + printf("\n 6\n"); + + scanf_s(" %[^\n]", &str, 100); + + printf("%s\n", str); + + for (int i = 0; i < strlen(str); i++) + str[i] = toUpperCase(str[i]); + + printf("%s\n", str); + + + + printf("\n 9 8\n"); + + scanf_s(" %[^\n]", &str, 100); + + printf("%s\n", str); + + for (int i = 0; i < strlen(str); i++) + if(!(str[i] >= 'a' && str[i] <= 'z' || str[i] >= 'A' && str[i] <= 'Z')) + str[i] = '_'; + + printf("%s\n", str); + + return 0; +} + +int isDigit(char c) { + return c > '0' && c <= '9'; +} + +char toUpperCase(char c) { + if (c >= 'a' && c <= 'z') return 'A' + (c - 'a'); + if (c == '') return ''; + return c; +} \ No newline at end of file diff --git a/21-22/22.c b/21-22/22.c new file mode 100644 index 0000000..f88f9a6 --- /dev/null +++ b/21-22/22.c @@ -0,0 +1,99 @@ +#include "stdio.h" +#include "string.h" +#include "Windows.h" + +int mystrlen(char[]), mystrlenpoint(char*); +int mystrcmp(char[], char[]), mystrcmppoint(char*, char*); +void mystrcpy(char*, char*); +void mystrcat(char*, char*); +void mystrcpyn(char*, char*, int); + +int main() { + char str[100]; + char str1[100]; + int n; + + printf("cpyn\n"); + scanf_s(" %[^\n]", &str1, 100); + scanf_s("%d", &n); + mystrcpyn(&str, &str1, n); + printf("1 = %s, 2 = %s\n", str, str1); + + printf("len\n"); + scanf_s(" %[^\n]", &str, 100); + printf("len = %d\n", mystrlen(str)); + + printf("len pointer\n"); + scanf_s(" %[^\n]", &str, 100); + printf("len pointer = %d\n", mystrlenpoint(&str)); + + printf("cmp\n"); + scanf_s(" %[^\n]", &str, 100); + scanf_s(" %[^\n]", &str1, 100); + printf("str - str1 = %d\n", mystrcmp(str, str1)); + + + printf("cmp pointer\n"); + scanf_s(" %[^\n]", &str, 100); + scanf_s(" %[^\n]", &str1, 100); + printf("str - str1 = %d\n", mystrcmppoint(&str, &str1)); + + printf("cpy\n"); + scanf_s(" %[^\n]", &str1, 100); + mystrcpy(str, str1); + printf("1 = %s, 2 = %s\n", str, str1); + + printf("cat\n"); + scanf_s(" %[^\n]", &str, 100); + scanf_s(" %[^\n]", &str1, 100); + mystrcat(str, str1); + printf("%s", str); + + + return 0; +} + +int mystrlen(char c[]) { + int k = 0; + for (int i = 0; c[i] != '\0'; i++) k++; + return k; +} + +int mystrlenpoint(char *c) { + char* p = c; + while (*p++); + return p - c - 1; +} + +int mystrcmp(char f[], char s[]) { + int i; + for (i = 0; f[i] != '\0' && s[i] != "\0"; i++) { + if (f[i] - s[i] != 0) break; + } + return f[i] - s[i]; +} + +int mystrcmppoint(char *f, char *s) { + int i; + for (i = 0; f[i] != '\0' && s[i] != "\0"; i++) { + if (f[i] - s[i] != 0) break; + } + return f[i] - s[i]; +} + +void mystrcpy(char *f, char *s) { + while (*f++ = *s++); +} + +void mystrcat(char* f, char* s) { + while (*f) *f++; + while (*f++ = *s++); +} + +void mystrcpyn(char* f, char* s, int n) { + int i = 0; + for (i = 0; s[i] != '\0' && i < n; i++) { + f[i] = s[i]; + } + f[i] = '\0'; +} \ No newline at end of file diff --git a/21-22/desktop.ini b/21-22/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/21-22/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/23-24/23-24.vcxproj b/23-24/23-24.vcxproj new file mode 100644 index 0000000..7dc0feb --- /dev/null +++ b/23-24/23-24.vcxproj @@ -0,0 +1,136 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {a1aa69ee-c137-4f84-ac0f-b33c2b861640} + My2324 + 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/23-24/23-24.vcxproj.filters b/23-24/23-24.vcxproj.filters new file mode 100644 index 0000000..0c7eb29 --- /dev/null +++ b/23-24/23-24.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {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/23-24/23.c b/23-24/23.c new file mode 100644 index 0000000..d7031fb --- /dev/null +++ b/23-24/23.c @@ -0,0 +1,116 @@ +#include "stdio.h" +#include "Windows.h" + +#define MAX_LEN 80 +char s[MAX_LEN]; + +void Z1(), Z2(), Z4(); + +int main1() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + + Z1(); + Z2(); + Z4(); + + return 0; +} + +void Z1() { + FILE* fin; + fopen_s(&fin, "D:\\university\\\\lab\\Temp\\23-24\\in1.txt", "rt"); + if (fin == NULL) { + printf(" "); + return; + } + + FILE* fout; + fopen_s(&fout, "D:\\university\\\\lab\\Temp\\23-24\\out1.txt", "wt"); + if (fout == NULL) { + printf(" "); + return; + } + + while (!feof(fin)) { + if (fgets(s, MAX_LEN, fin) != NULL) { + for (int i = 0; s[i] != '\0'; i++) { + if (s[i] == '\t') { + s[i] = '%'; + } + } + fprintf(fout, "%s", s); + printf(">>%s<<\n", s); + } + } + + fclose(fin); + fclose(fout); +} + +char toUpperCase(char c) { + if (c >= 'a' && c <= 'z') return 'A' + (c - 'a'); + //printf(" %d = %c ", c, c); + if (c >= '' && c <= '') return '' + (c - ''); + if (c == '') return ''; + return c; +} + +void Z2() { + FILE* fin; + fopen_s(&fin, "D:\\university\\\\lab\\Temp\\23-24\\in2.txt", "rt"); + if (fin == NULL) { + printf(" "); + return; + } + + FILE* fout; + fopen_s(&fout, "D:\\university\\\\lab\\Temp\\23-24\\out2.txt", "wt"); + if (fout == NULL) { + printf(" "); + return; + } + + while (!feof(fin)) { + if (fgets(s, MAX_LEN, fin) != NULL) { + for (int i = 0; s[i] != '\0'; i++) { + s[i] = toUpperCase(s[i]); + } + fprintf(fout, "%s", s); + printf(">>%s<<\n", s); + } + } + + fclose(fin); + fclose(fout); +} + +void Z4() { + FILE* fin; + fopen_s(&fin, "D:\\university\\\\lab\\Temp\\23-24\\in4.txt", "rt"); + if (fin == NULL) { + printf(" "); + return; + } + + FILE* fout; + fopen_s(&fout, "D:\\university\\\\lab\\Temp\\23-24\\out4.txt", "wt"); + if (fout == NULL) { + printf(" "); + return; + } + + while (!feof(fin)) { + if (fgets(s, MAX_LEN, fin) != NULL) { + for (int i = 0; s[i] != '\0'; i++) { + if (!((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))) + s[i] = '_'; + } + fprintf(fout, "%s", s); + printf(">>%s<<\n", s); + } + } + + fclose(fin); + fclose(fout); +} \ No newline at end of file diff --git a/23-24/24.c b/23-24/24.c new file mode 100644 index 0000000..f792a14 --- /dev/null +++ b/23-24/24.c @@ -0,0 +1,110 @@ +#include "stdio.h" +#include "Windows.h" + +#define MAX_LEN 80 +char s[MAX_LEN]; + +void Z1html(), Z2html(); + +int main() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + + Z1html(); + Z2html(); + + return 0; +} + +void Z1html() { + FILE* fin; + fopen_s(&fin, "D:\\university\\\\lab\\Temp\\23-24\\in1html.txt", "rt"); + if (fin == NULL) { + printf(" "); + return; + } + + FILE* fout; + fopen_s(&fout, "D:\\university\\\\lab\\Temp\\23-24\\out1html.html", "wt"); + if (fout == NULL) { + printf(" "); + return; + } + + fprintf(fout, "HTML Document"); + + while (!feof(fin)) { + if (fgets(s, MAX_LEN, fin) != NULL) { + fprintf(fout, "%s
", s); + } + } + + fprintf(fout, ""); + + fclose(fin); + fclose(fout); +} + +void Z2html() { + FILE* fin; + fopen_s(&fin, "D:\\university\\\\lab\\Temp\\23-24\\in2html.txt", "rt"); + if (fin == NULL) { + printf(" "); + return; + } + + FILE* fout; + fopen_s(&fout, "D:\\university\\\\lab\\Temp\\23-24\\out2html.html", "wt"); + if (fout == NULL) { + printf(" "); + return; + } + + fprintf(fout, "HTML Document"); + + while (!feof(fin)) { + if (fgets(s, MAX_LEN, fin) != NULL) { + int bold = 0; + for (int i = 0; s[i] != '\0'; i++) { + if (s[i + 1] == '\0') break; + for (int j = i+1; s[j] != '\0'; j++) { + if (s[i] == s[j]) { + bold = 1; + break; + } + } + if (bold) break; + } + + + + int italic = 1; + for (int i = 0; s[i] != '\0'; i++) { + if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= '' && s[i] <= '')) + { + italic = 0; + break; + } + } + + if (bold && italic) { + fprintf(fout, "%s
", s); + continue; + } + if (bold) { + fprintf(fout, "%s
", s); + continue; + } + if (italic) { + fprintf(fout, "%s
", s); + continue; + } + fprintf(fout, "%s
", s); + } + } + + fprintf(fout, ""); + + fclose(fin); + fclose(fout); +} \ No newline at end of file diff --git a/23-24/desktop.ini b/23-24/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/23-24/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/910/910.vcxproj b/910/910.vcxproj new file mode 100644 index 0000000..5146a30 --- /dev/null +++ b/910/910.vcxproj @@ -0,0 +1,140 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {123e7787-05e1-478d-9cb1-f08abc0ab429} + My910 + 10.0 + 9-10 + + + + 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/910/910.vcxproj.filters b/910/910.vcxproj.filters new file mode 100644 index 0000000..65e2b54 --- /dev/null +++ b/910/910.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {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/910/desktop.ini b/910/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/910/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/910/func.c b/910/func.c new file mode 100644 index 0000000..8446d7d --- /dev/null +++ b/910/func.c @@ -0,0 +1,181 @@ +#include "func.h" + +#ifdef Z1 + void ot1do10(), ot10do1(), ot1_5odd(), ot1do100_10(), ot1000do100_100(), ot1000do0(); + + void Menu() { + int n; + + do + { + printf(" :\n"); + printf("1) 1 10\n"); + printf("2) 10 1\n"); + printf("3) 5 1\n"); + printf("11) 10 10 100\n"); + printf("12) 10 1000 100\n"); + printf("20) 1000 0 \n\n"); + printf("99) \n"); + + scanf_s("%d", &n); + + switch (n) + { + case 1: + ot1do10(); + break; + case 2: + ot10do1(); + break; + case 3: + ot1_5odd(); + break; + case 11: + ot1do100_10(); + break; + case 12: + ot1000do100_100(); + break; + case 20: + ot1000do0(); + break; + } + + } while (n != 99); + } + + void twospace() { + printf("\n\n"); + } + + void ot1do10() { + int i = 1; + while (i <= 10) { + printf("%d ", i++); + } + twospace(); + } + + void ot10do1() { + int i = 10; + while (i >= 1) { + printf("%d ", i--); + } + twospace(); + } + + void ot1_5odd() { + int i = 0; + while (i <= 4) { + printf("%d ", 2 * i + 1); + i++; + } + twospace(); + } + + void ot1do100_10() { + int i = 1; + while (i <= 10) { + printf("%d ", i * 10); + i++; + } + twospace(); + } + + void ot1000do100_100() { + int i = 10; + while (i >= 1) { + printf("%d ", i * 100); + i--; + } + twospace(); + } + + void ot1000do0() { + int i = 1000; + int shag; + printf(" :"); + scanf_s("%d", &shag); + cycle: + printf("%d ", i); + i -= shag; + if (i > 0) goto cycle; + printf("%d", 0); + twospace(); + } +#endif + +#ifdef Z2 + void pif(), MN(), triangle(); + + void Menu() { + int n; + + do + { + printf(" :\n"); + printf("1) \n"); + printf("2) M N \n"); + printf("3) \n\n"); + printf("99) \n"); + + scanf_s("%d", &n); + + switch (n) + { + case 1: + pif(); + break; + case 2: + MN(); + break; + case 3: + triangle(); + break; + } + + } while (n != 99); + } + + void MN() { + int M = 0, N = 0; + printf(" M N\n"); + scanf_s("%d%d", &M, &N); + int i = 1; + while (i <= M) { + int j = 1; + while (j <= N) { + printf("%d%d ", i, j); + j++; + } + printf("\n\n"); + i++; + } + } + + void triangle() { + int i = 0; + do { + int j = 0; + while (j < i+1) { + printf("%d ", 5-j); + j++; + } + i++; + printf("\n"); + } while (i < 5); + } + + void pif() { + int i = 1; + while (i <= 10) { + int j = 1; + while (j <= 10) { + printf("%3d ", i * j); + j++; + } + printf("\n\n"); + i++; + } + } +#endif \ No newline at end of file diff --git a/910/func.h b/910/func.h new file mode 100644 index 0000000..6fe773f --- /dev/null +++ b/910/func.h @@ -0,0 +1,6 @@ +#pragma once +#include + +#define Z2 + +void Menu(); \ No newline at end of file diff --git a/910/lab.c b/910/lab.c new file mode 100644 index 0000000..3d52a80 --- /dev/null +++ b/910/lab.c @@ -0,0 +1,13 @@ +#include +#include +#include "func.h" + + +int main() { + SetConsoleCP(1251); + SetConsoleOutputCP(1251); + + Menu(); + + return 0; +} \ No newline at end of file diff --git a/Temp/19-20/desktop.ini b/Temp/19-20/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/Temp/19-20/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/Temp/19-20/in1.txt b/Temp/19-20/in1.txt new file mode 100644 index 0000000..e1c2efe --- /dev/null +++ b/Temp/19-20/in1.txt @@ -0,0 +1,2 @@ +6 +3 2 4 2 2 5 diff --git a/Temp/19-20/in2.txt b/Temp/19-20/in2.txt new file mode 100644 index 0000000..08299d7 --- /dev/null +++ b/Temp/19-20/in2.txt @@ -0,0 +1,2 @@ +6 +3 2 4 2 2 5 \ No newline at end of file diff --git a/Temp/19-20/in3.txt b/Temp/19-20/in3.txt new file mode 100644 index 0000000..c581681 --- /dev/null +++ b/Temp/19-20/in3.txt @@ -0,0 +1,2 @@ +6 +-10 -5 -1 2 6 25 \ No newline at end of file diff --git a/Temp/19-20/in4.txt b/Temp/19-20/in4.txt new file mode 100644 index 0000000..8adcc0f --- /dev/null +++ b/Temp/19-20/in4.txt @@ -0,0 +1,2 @@ +8 +10000 20000 35000 20000 50000 60000 18000 45000 \ No newline at end of file diff --git a/Temp/23-24/desktop.ini b/Temp/23-24/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/Temp/23-24/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/Temp/23-24/in1.txt b/Temp/23-24/in1.txt new file mode 100644 index 0000000..7bddc36 --- /dev/null +++ b/Temp/23-24/in1.txt @@ -0,0 +1 @@ +asdasd assdasdasd asd \ No newline at end of file diff --git a/Temp/23-24/in1html.txt b/Temp/23-24/in1html.txt new file mode 100644 index 0000000..418fccd --- /dev/null +++ b/Temp/23-24/in1html.txt @@ -0,0 +1,17 @@ +asdasd assdasdasd asd +asd +asdasd +asdasd + + +asd + + + + + +asdasd + + + +asd \ No newline at end of file diff --git a/Temp/23-24/in2.txt b/Temp/23-24/in2.txt new file mode 100644 index 0000000..041886a --- /dev/null +++ b/Temp/23-24/in2.txt @@ -0,0 +1 @@ +asdфывASD123fh \ No newline at end of file diff --git a/Temp/23-24/in2html.txt b/Temp/23-24/in2html.txt new file mode 100644 index 0000000..a37e34f --- /dev/null +++ b/Temp/23-24/in2html.txt @@ -0,0 +1,5 @@ +aasd +ASD +AASD +aaaaaa +asdgasfgafsg \ No newline at end of file diff --git a/Temp/23-24/in4.txt b/Temp/23-24/in4.txt new file mode 100644 index 0000000..2dc64cd --- /dev/null +++ b/Temp/23-24/in4.txt @@ -0,0 +1 @@ +asd asd фывфвыа фыап 12312 2451 231235 \ No newline at end of file diff --git a/Temp/23-24/out1.txt b/Temp/23-24/out1.txt new file mode 100644 index 0000000..d070368 --- /dev/null +++ b/Temp/23-24/out1.txt @@ -0,0 +1 @@ +asdasd%assdasdasd%%%asd \ No newline at end of file diff --git a/Temp/23-24/out1html.html b/Temp/23-24/out1html.html new file mode 100644 index 0000000..3702d8f --- /dev/null +++ b/Temp/23-24/out1html.html @@ -0,0 +1,17 @@ +HTML Documentasdasd assdasdasd asd +
asd +
asdasd +
asdasd +
+
+
asd +
+
+
+
+
+
asdasd +
+
+
+
asd
\ No newline at end of file diff --git a/Temp/23-24/out2.txt b/Temp/23-24/out2.txt new file mode 100644 index 0000000..21dbeb6 --- /dev/null +++ b/Temp/23-24/out2.txt @@ -0,0 +1 @@ +ASDфывASD123FH \ No newline at end of file diff --git a/Temp/23-24/out2html.html b/Temp/23-24/out2html.html new file mode 100644 index 0000000..ab2a085 --- /dev/null +++ b/Temp/23-24/out2html.html @@ -0,0 +1,5 @@ +HTML Documentaasd +
ASD +
AASD +
aaaaaa +
asdgasfgafsg
\ No newline at end of file diff --git a/Temp/23-24/out4.txt b/Temp/23-24/out4.txt new file mode 100644 index 0000000..cc5d29f --- /dev/null +++ b/Temp/23-24/out4.txt @@ -0,0 +1 @@ +asd_asd____________________________________________ \ No newline at end of file diff --git a/Temp/desktop.ini b/Temp/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/Temp/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/Temp/game.bin b/Temp/game.bin new file mode 100644 index 0000000..926ef0b Binary files /dev/null and b/Temp/game.bin differ diff --git a/Temp/start.bin b/Temp/start.bin new file mode 100644 index 0000000..09b689c Binary files /dev/null and b/Temp/start.bin differ diff --git a/Temp/test.txt b/Temp/test.txt new file mode 100644 index 0000000..14a3599 --- /dev/null +++ b/Temp/test.txt @@ -0,0 +1,4 @@ +3 3 +1 2 3 +4 5 6 +7 8 9 diff --git a/additional_materials/L13-14/Z1.png b/additional_materials/L13-14/Z1.png new file mode 100644 index 0000000..0faac53 Binary files /dev/null and b/additional_materials/L13-14/Z1.png differ diff --git a/additional_materials/L13-14/Z2.png b/additional_materials/L13-14/Z2.png new file mode 100644 index 0000000..f115076 Binary files /dev/null and b/additional_materials/L13-14/Z2.png differ diff --git a/additional_materials/L13-14/desktop.ini b/additional_materials/L13-14/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/additional_materials/L13-14/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/additional_materials/L18/Z5.png b/additional_materials/L18/Z5.png new file mode 100644 index 0000000..669a90e Binary files /dev/null and b/additional_materials/L18/Z5.png differ diff --git a/additional_materials/L18/desktop.ini b/additional_materials/L18/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/additional_materials/L18/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/additional_materials/L3/L3Z2.png b/additional_materials/L3/L3Z2.png new file mode 100644 index 0000000..b175fc8 Binary files /dev/null and b/additional_materials/L3/L3Z2.png differ diff --git a/additional_materials/L3/L3Z3.png b/additional_materials/L3/L3Z3.png new file mode 100644 index 0000000..cb4709a Binary files /dev/null and b/additional_materials/L3/L3Z3.png differ diff --git a/additional_materials/L3/L3Z5.png b/additional_materials/L3/L3Z5.png new file mode 100644 index 0000000..53e3fe2 Binary files /dev/null and b/additional_materials/L3/L3Z5.png differ diff --git a/additional_materials/L3/L3Z6.png b/additional_materials/L3/L3Z6.png new file mode 100644 index 0000000..b118772 Binary files /dev/null and b/additional_materials/L3/L3Z6.png differ diff --git a/additional_materials/L3/desktop.ini b/additional_materials/L3/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/additional_materials/L3/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/additional_materials/L4/L4Z2.png b/additional_materials/L4/L4Z2.png new file mode 100644 index 0000000..7955040 Binary files /dev/null and b/additional_materials/L4/L4Z2.png differ diff --git a/additional_materials/L4/L4Z4.png b/additional_materials/L4/L4Z4.png new file mode 100644 index 0000000..3618fb8 Binary files /dev/null and b/additional_materials/L4/L4Z4.png differ diff --git a/additional_materials/L4/L4Z6.png b/additional_materials/L4/L4Z6.png new file mode 100644 index 0000000..7adba32 Binary files /dev/null and b/additional_materials/L4/L4Z6.png differ diff --git a/additional_materials/L4/L4Z7.png b/additional_materials/L4/L4Z7.png new file mode 100644 index 0000000..9baf7ea Binary files /dev/null and b/additional_materials/L4/L4Z7.png differ diff --git a/additional_materials/L4/desktop.ini b/additional_materials/L4/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/additional_materials/L4/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/additional_materials/L7/L7Z1.png b/additional_materials/L7/L7Z1.png new file mode 100644 index 0000000..a1c43ae Binary files /dev/null and b/additional_materials/L7/L7Z1.png differ diff --git a/additional_materials/L7/desktop.ini b/additional_materials/L7/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/additional_materials/L7/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/additional_materials/L8/L8Z5.png b/additional_materials/L8/L8Z5.png new file mode 100644 index 0000000..0372173 Binary files /dev/null and b/additional_materials/L8/L8Z5.png differ diff --git a/additional_materials/L8/desktop.ini b/additional_materials/L8/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/additional_materials/L8/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/additional_materials/L9/Z3.png b/additional_materials/L9/Z3.png new file mode 100644 index 0000000..de11b03 Binary files /dev/null and b/additional_materials/L9/Z3.png differ diff --git a/additional_materials/L9/Z5.png b/additional_materials/L9/Z5.png new file mode 100644 index 0000000..4f91c2a Binary files /dev/null and b/additional_materials/L9/Z5.png differ diff --git a/additional_materials/L9/Zpif.png b/additional_materials/L9/Zpif.png new file mode 100644 index 0000000..427fdf9 Binary files /dev/null and b/additional_materials/L9/Zpif.png differ diff --git a/additional_materials/L9/desktop.ini b/additional_materials/L9/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/additional_materials/L9/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/additional_materials/L9/tracing MN.png b/additional_materials/L9/tracing MN.png new file mode 100644 index 0000000..c41a0b4 Binary files /dev/null and b/additional_materials/L9/tracing MN.png differ diff --git a/additional_materials/desktop.ini b/additional_materials/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/additional_materials/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/desktop.ini b/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/lab.sln b/lab.sln new file mode 100644 index 0000000..dfaf141 --- /dev/null +++ b/lab.sln @@ -0,0 +1,141 @@ + +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}") = "lab", "lab\lab.vcxproj", "{84206DEA-52A8-4FDC-88AE-19EAB48F0D52}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "window", "window\window.vcxproj", "{6DF1E650-4412-4CE1-A5DB-7D0A3C2EB2EC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "9-10", "910\910.vcxproj", "{123E7787-05E1-478D-9CB1-F08ABC0AB429}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "11", "11\11.vcxproj", "{FD72AA5A-14F6-4851-83A9-B1D6948B0C86}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "13-14", "13-14\13-14.vcxproj", "{161816FB-DA2B-43F7-8CFE-2F3A03BF2F97}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "15", "15\15.vcxproj", "{8CBC5826-531F-45FD-AA76-17DCD4E25D30}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "16", "16\16.vcxproj", "{CA6A78F7-F0CF-443E-A713-347385883516}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "17", "17\17.vcxproj", "{85E1E279-BFCA-48F2-AD89-22F8B3934CA4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "18", "18\18.vcxproj", "{4839DA26-FEBA-494B-AA4A-AF4A46C6BA51}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "19-20", "19-20\19-20.vcxproj", "{969AD85F-9A3B-4A45-B60C-147307EC5453}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "21-22", "21-22\21-22.vcxproj", "{5FA1270B-CD23-45E0-85B8-08B50975C2B9}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "23-24", "23-24\23-24.vcxproj", "{A1AA69EE-C137-4F84-AC0F-B33C2B861640}" +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 + {84206DEA-52A8-4FDC-88AE-19EAB48F0D52}.Debug|x64.ActiveCfg = Debug|x64 + {84206DEA-52A8-4FDC-88AE-19EAB48F0D52}.Debug|x64.Build.0 = Debug|x64 + {84206DEA-52A8-4FDC-88AE-19EAB48F0D52}.Debug|x86.ActiveCfg = Debug|Win32 + {84206DEA-52A8-4FDC-88AE-19EAB48F0D52}.Debug|x86.Build.0 = Debug|Win32 + {84206DEA-52A8-4FDC-88AE-19EAB48F0D52}.Release|x64.ActiveCfg = Release|x64 + {84206DEA-52A8-4FDC-88AE-19EAB48F0D52}.Release|x64.Build.0 = Release|x64 + {84206DEA-52A8-4FDC-88AE-19EAB48F0D52}.Release|x86.ActiveCfg = Release|Win32 + {84206DEA-52A8-4FDC-88AE-19EAB48F0D52}.Release|x86.Build.0 = Release|Win32 + {6DF1E650-4412-4CE1-A5DB-7D0A3C2EB2EC}.Debug|x64.ActiveCfg = Debug|x64 + {6DF1E650-4412-4CE1-A5DB-7D0A3C2EB2EC}.Debug|x64.Build.0 = Debug|x64 + {6DF1E650-4412-4CE1-A5DB-7D0A3C2EB2EC}.Debug|x86.ActiveCfg = Debug|Win32 + {6DF1E650-4412-4CE1-A5DB-7D0A3C2EB2EC}.Debug|x86.Build.0 = Debug|Win32 + {6DF1E650-4412-4CE1-A5DB-7D0A3C2EB2EC}.Release|x64.ActiveCfg = Release|x64 + {6DF1E650-4412-4CE1-A5DB-7D0A3C2EB2EC}.Release|x64.Build.0 = Release|x64 + {6DF1E650-4412-4CE1-A5DB-7D0A3C2EB2EC}.Release|x86.ActiveCfg = Release|Win32 + {6DF1E650-4412-4CE1-A5DB-7D0A3C2EB2EC}.Release|x86.Build.0 = Release|Win32 + {123E7787-05E1-478D-9CB1-F08ABC0AB429}.Debug|x64.ActiveCfg = Debug|x64 + {123E7787-05E1-478D-9CB1-F08ABC0AB429}.Debug|x64.Build.0 = Debug|x64 + {123E7787-05E1-478D-9CB1-F08ABC0AB429}.Debug|x86.ActiveCfg = Debug|Win32 + {123E7787-05E1-478D-9CB1-F08ABC0AB429}.Debug|x86.Build.0 = Debug|Win32 + {123E7787-05E1-478D-9CB1-F08ABC0AB429}.Release|x64.ActiveCfg = Release|x64 + {123E7787-05E1-478D-9CB1-F08ABC0AB429}.Release|x64.Build.0 = Release|x64 + {123E7787-05E1-478D-9CB1-F08ABC0AB429}.Release|x86.ActiveCfg = Release|Win32 + {123E7787-05E1-478D-9CB1-F08ABC0AB429}.Release|x86.Build.0 = Release|Win32 + {FD72AA5A-14F6-4851-83A9-B1D6948B0C86}.Debug|x64.ActiveCfg = Debug|x64 + {FD72AA5A-14F6-4851-83A9-B1D6948B0C86}.Debug|x64.Build.0 = Debug|x64 + {FD72AA5A-14F6-4851-83A9-B1D6948B0C86}.Debug|x86.ActiveCfg = Debug|Win32 + {FD72AA5A-14F6-4851-83A9-B1D6948B0C86}.Debug|x86.Build.0 = Debug|Win32 + {FD72AA5A-14F6-4851-83A9-B1D6948B0C86}.Release|x64.ActiveCfg = Release|x64 + {FD72AA5A-14F6-4851-83A9-B1D6948B0C86}.Release|x64.Build.0 = Release|x64 + {FD72AA5A-14F6-4851-83A9-B1D6948B0C86}.Release|x86.ActiveCfg = Release|Win32 + {FD72AA5A-14F6-4851-83A9-B1D6948B0C86}.Release|x86.Build.0 = Release|Win32 + {161816FB-DA2B-43F7-8CFE-2F3A03BF2F97}.Debug|x64.ActiveCfg = Debug|x64 + {161816FB-DA2B-43F7-8CFE-2F3A03BF2F97}.Debug|x64.Build.0 = Debug|x64 + {161816FB-DA2B-43F7-8CFE-2F3A03BF2F97}.Debug|x86.ActiveCfg = Debug|Win32 + {161816FB-DA2B-43F7-8CFE-2F3A03BF2F97}.Debug|x86.Build.0 = Debug|Win32 + {161816FB-DA2B-43F7-8CFE-2F3A03BF2F97}.Release|x64.ActiveCfg = Release|x64 + {161816FB-DA2B-43F7-8CFE-2F3A03BF2F97}.Release|x64.Build.0 = Release|x64 + {161816FB-DA2B-43F7-8CFE-2F3A03BF2F97}.Release|x86.ActiveCfg = Release|Win32 + {161816FB-DA2B-43F7-8CFE-2F3A03BF2F97}.Release|x86.Build.0 = Release|Win32 + {8CBC5826-531F-45FD-AA76-17DCD4E25D30}.Debug|x64.ActiveCfg = Debug|x64 + {8CBC5826-531F-45FD-AA76-17DCD4E25D30}.Debug|x64.Build.0 = Debug|x64 + {8CBC5826-531F-45FD-AA76-17DCD4E25D30}.Debug|x86.ActiveCfg = Debug|Win32 + {8CBC5826-531F-45FD-AA76-17DCD4E25D30}.Debug|x86.Build.0 = Debug|Win32 + {8CBC5826-531F-45FD-AA76-17DCD4E25D30}.Release|x64.ActiveCfg = Release|x64 + {8CBC5826-531F-45FD-AA76-17DCD4E25D30}.Release|x64.Build.0 = Release|x64 + {8CBC5826-531F-45FD-AA76-17DCD4E25D30}.Release|x86.ActiveCfg = Release|Win32 + {8CBC5826-531F-45FD-AA76-17DCD4E25D30}.Release|x86.Build.0 = Release|Win32 + {CA6A78F7-F0CF-443E-A713-347385883516}.Debug|x64.ActiveCfg = Debug|x64 + {CA6A78F7-F0CF-443E-A713-347385883516}.Debug|x64.Build.0 = Debug|x64 + {CA6A78F7-F0CF-443E-A713-347385883516}.Debug|x86.ActiveCfg = Debug|Win32 + {CA6A78F7-F0CF-443E-A713-347385883516}.Debug|x86.Build.0 = Debug|Win32 + {CA6A78F7-F0CF-443E-A713-347385883516}.Release|x64.ActiveCfg = Release|x64 + {CA6A78F7-F0CF-443E-A713-347385883516}.Release|x64.Build.0 = Release|x64 + {CA6A78F7-F0CF-443E-A713-347385883516}.Release|x86.ActiveCfg = Release|Win32 + {CA6A78F7-F0CF-443E-A713-347385883516}.Release|x86.Build.0 = Release|Win32 + {85E1E279-BFCA-48F2-AD89-22F8B3934CA4}.Debug|x64.ActiveCfg = Debug|x64 + {85E1E279-BFCA-48F2-AD89-22F8B3934CA4}.Debug|x64.Build.0 = Debug|x64 + {85E1E279-BFCA-48F2-AD89-22F8B3934CA4}.Debug|x86.ActiveCfg = Debug|Win32 + {85E1E279-BFCA-48F2-AD89-22F8B3934CA4}.Debug|x86.Build.0 = Debug|Win32 + {85E1E279-BFCA-48F2-AD89-22F8B3934CA4}.Release|x64.ActiveCfg = Release|x64 + {85E1E279-BFCA-48F2-AD89-22F8B3934CA4}.Release|x64.Build.0 = Release|x64 + {85E1E279-BFCA-48F2-AD89-22F8B3934CA4}.Release|x86.ActiveCfg = Release|Win32 + {85E1E279-BFCA-48F2-AD89-22F8B3934CA4}.Release|x86.Build.0 = Release|Win32 + {4839DA26-FEBA-494B-AA4A-AF4A46C6BA51}.Debug|x64.ActiveCfg = Debug|x64 + {4839DA26-FEBA-494B-AA4A-AF4A46C6BA51}.Debug|x64.Build.0 = Debug|x64 + {4839DA26-FEBA-494B-AA4A-AF4A46C6BA51}.Debug|x86.ActiveCfg = Debug|Win32 + {4839DA26-FEBA-494B-AA4A-AF4A46C6BA51}.Debug|x86.Build.0 = Debug|Win32 + {4839DA26-FEBA-494B-AA4A-AF4A46C6BA51}.Release|x64.ActiveCfg = Release|x64 + {4839DA26-FEBA-494B-AA4A-AF4A46C6BA51}.Release|x64.Build.0 = Release|x64 + {4839DA26-FEBA-494B-AA4A-AF4A46C6BA51}.Release|x86.ActiveCfg = Release|Win32 + {4839DA26-FEBA-494B-AA4A-AF4A46C6BA51}.Release|x86.Build.0 = Release|Win32 + {969AD85F-9A3B-4A45-B60C-147307EC5453}.Debug|x64.ActiveCfg = Debug|x64 + {969AD85F-9A3B-4A45-B60C-147307EC5453}.Debug|x64.Build.0 = Debug|x64 + {969AD85F-9A3B-4A45-B60C-147307EC5453}.Debug|x86.ActiveCfg = Debug|Win32 + {969AD85F-9A3B-4A45-B60C-147307EC5453}.Debug|x86.Build.0 = Debug|Win32 + {969AD85F-9A3B-4A45-B60C-147307EC5453}.Release|x64.ActiveCfg = Release|x64 + {969AD85F-9A3B-4A45-B60C-147307EC5453}.Release|x64.Build.0 = Release|x64 + {969AD85F-9A3B-4A45-B60C-147307EC5453}.Release|x86.ActiveCfg = Release|Win32 + {969AD85F-9A3B-4A45-B60C-147307EC5453}.Release|x86.Build.0 = Release|Win32 + {5FA1270B-CD23-45E0-85B8-08B50975C2B9}.Debug|x64.ActiveCfg = Debug|x64 + {5FA1270B-CD23-45E0-85B8-08B50975C2B9}.Debug|x64.Build.0 = Debug|x64 + {5FA1270B-CD23-45E0-85B8-08B50975C2B9}.Debug|x86.ActiveCfg = Debug|Win32 + {5FA1270B-CD23-45E0-85B8-08B50975C2B9}.Debug|x86.Build.0 = Debug|Win32 + {5FA1270B-CD23-45E0-85B8-08B50975C2B9}.Release|x64.ActiveCfg = Release|x64 + {5FA1270B-CD23-45E0-85B8-08B50975C2B9}.Release|x64.Build.0 = Release|x64 + {5FA1270B-CD23-45E0-85B8-08B50975C2B9}.Release|x86.ActiveCfg = Release|Win32 + {5FA1270B-CD23-45E0-85B8-08B50975C2B9}.Release|x86.Build.0 = Release|Win32 + {A1AA69EE-C137-4F84-AC0F-B33C2B861640}.Debug|x64.ActiveCfg = Debug|x64 + {A1AA69EE-C137-4F84-AC0F-B33C2B861640}.Debug|x64.Build.0 = Debug|x64 + {A1AA69EE-C137-4F84-AC0F-B33C2B861640}.Debug|x86.ActiveCfg = Debug|Win32 + {A1AA69EE-C137-4F84-AC0F-B33C2B861640}.Debug|x86.Build.0 = Debug|Win32 + {A1AA69EE-C137-4F84-AC0F-B33C2B861640}.Release|x64.ActiveCfg = Release|x64 + {A1AA69EE-C137-4F84-AC0F-B33C2B861640}.Release|x64.Build.0 = Release|x64 + {A1AA69EE-C137-4F84-AC0F-B33C2B861640}.Release|x86.ActiveCfg = Release|Win32 + {A1AA69EE-C137-4F84-AC0F-B33C2B861640}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E0D7DD59-2637-4750-B687-A03287F6AA7B} + EndGlobalSection +EndGlobal diff --git a/lab/desktop.ini b/lab/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/lab/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/lab/lab.vcxproj b/lab/lab.vcxproj new file mode 100644 index 0000000..65a826d --- /dev/null +++ b/lab/lab.vcxproj @@ -0,0 +1,138 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {84206dea-52a8-4fdc-88ae-19eab48f0d52} + lab + 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/lab/lab.vcxproj.filters b/lab/lab.vcxproj.filters new file mode 100644 index 0000000..ee3ac9b --- /dev/null +++ b/lab/lab.vcxproj.filters @@ -0,0 +1,31 @@ + + + + + {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/lab/lab1.c b/lab/lab1.c new file mode 100644 index 0000000..223a2be --- /dev/null +++ b/lab/lab1.c @@ -0,0 +1,57 @@ +#include +#include + +void aboutMe() { + printf("\n\n\n"); + printf("-12\n"); + printf("24.09.2024\n"); + printf(" \n"); + printf(" 8\n\n"); +} + +int main1() { + setlocale(LC_ALL, "RU"); + + aboutMe(); + + //printf("Hello World!\n\n\n"); + + //printf(" \n"); + //printf("-12\n"); + //printf("04.09.2024\n\n"); + + //printf("04.09.2024\n"); + //printf("-12\n"); + //printf(" \n\n\n"); + + //printf(" \n"); + //printf("-12\n"); + //printf("04.09.2024\n\n"); + + //printf("04.09.2024\n"); + //printf("-12\n"); + //printf(" \n\n\n"); + + /*printf(" * \n"); + printf(" * * * \n"); + printf(" * * * \n"); + printf("* * * * * * *\n"); + printf(" * * * \n"); + printf(" * * * \n"); + printf(" / * \\ \n"); + printf(" // * \\\\ \n"); + printf(" /// * \\\\\\ \n"); + printf("__//// * \\\\\\\\__\n");*/ + + //printf(" *-----*\n"); + //printf(" / /|\n"); + //printf("*-----* |\n"); + //printf("| | |\n"); + //printf("| | |\n"); + //printf("| |/\n"); + //printf("*-----*\n"); + //printf("\n"); + //printf("\n"); + + return 0; +} \ No newline at end of file diff --git a/lab/lab2.c b/lab/lab2.c new file mode 100644 index 0000000..49c5833 --- /dev/null +++ b/lab/lab2.c @@ -0,0 +1,104 @@ +#include +#include +#define _USE_MATH_DEFINES +#include +#define g 9.8f + +void L2Z1(), L2Z2(), L2Z3(), L2Z4(), L2Z5(), L2Z6(), L2Z7(); + +int main2() { + system("chcp 1251"); + + //L2Z1(); + //L2Z2(); + //L2Z3(); + //L2Z4(); + //L2Z5(); + //L2Z6(); + L2Z7(); + + return 0; +} + +void L2Z1() { + float h = 12, t = sqrt(2 * h / g); + printf(" %.2f \n", t); +} + +void L2Z2() { + float h, t; + printf(" : "); + scanf_s("%f", &h); + t = sqrt(2 * h / g); + printf(" %.2f ", t); +} + +void L2Z3() { + float S; + int cost_per_meter; + printf(" .: "); + scanf_s("%f%d", &S, &cost_per_meter); + float price = S * cost_per_meter; + printf("%.2f", price); +} + +void L2Z4() { + float S, percent = 0.5; + int cost_per_meter, salary; + printf(" : "); + scanf_s("%f", &S); + printf(" 1 .: "); + scanf_s("%d", &cost_per_meter); + printf(" : "); + scanf_s("%d", &salary); + printf(" %f %d . %f\n", S, cost_per_meter, S * cost_per_meter); + float t = (S * cost_per_meter) / (salary * percent); + printf(" %d %1.2f ", salary, t); +} + +void L2Z5() { + float V, R, H; + printf(" \n"); + printf(" : "); + scanf_s("%f", &R); + printf(" : "); + scanf_s("%f", &H); + if (H > 2 * R) H = 2 * R; + V = M_PI * pow(H, 2) * (R - H / 3); + printf("V = %.2f", V); +} + +void L2Z6() { + float V, a; + printf(" \n"); + printf(" : "); + scanf_s("%f", &V); + printf(" : "); + scanf_s("%f", &a); + float S = pow(V, 2) * sinf(2 * a * M_PI / 180) / g; + float H = pow(V * sinf(a * M_PI / 180), 2) / 2 / g; + printf("L = %.2f\n", S); + printf("H = %.2f\n\n", H); +} + +void L2Z7() { + float A, r; + int n; + char currency[4]; + + printf(" \n"); + + printf(" : "); + scanf_s("%f", &A); + printf(" : "); + scanf_s("%d", &n); + printf(" : "); + scanf_s("%f", &r); + printf(" : "); + scanf_s("%s", currency, 4); + + + float S = A + ((A + A / n) * r * n / 2 / 100); + + printf(" %.2f %s\n %.2f %s\n\n", S, currency, S - A, currency); +} \ No newline at end of file diff --git a/lab/lab3.c b/lab/lab3.c new file mode 100644 index 0000000..37f7bd4 --- /dev/null +++ b/lab/lab3.c @@ -0,0 +1,217 @@ +#include +#include + +void L3Z1(); +int L3Z2(); +char* L3Z3(); +int L3Z4(); +char* L3Z5(); +char* L3Z6(); +char* L3Z7(); + +int main3() { + setlocale(LC_ALL, "RU"); + + //L3Z1(); + //L3Z2(); + //L3Z3(); + //L3Z4(); + //L3Z5(); + //L3Z6(); + //L3Z7(); + + return 0; +} + +void L3Z1() { + float a, b; + printf(" : "); + scanf_s("%f", &a); + printf(" : "); + scanf_s("%f", &b); + if (a == b) { + printf(" "); + } + else { + float max, min; + + if (a > b) { + max = a; + min = b; + } + else { + max = b; + min = a; + } + printf(" = %f\n = %f", max, min); + } +} + +int L3Z2() { + int a, b, c; + printf(" 3 : "); + scanf_s("%d %d %d", &a, &b, &c); + + + int max = a; + if (b > max) { + max = b; + } + if (c > max) { + max = c; + } + + printf("max = %d", max); + return max; +} + +char* L3Z3() { + int temperature; + char* ans = ""; + printf(" : "); + scanf_s("%d", &temperature); + if (temperature >= 18 && temperature < 22) { + ans = ""; + } + else if (temperature >= 22 && temperature < 26) { + ans = ""; + } + else if (temperature >= 26) { + ans = ""; + } + + printf("%s", ans); + return ans; +} + +int L3Z4() { + int a[5]; + printf(" 5 : "); + for (int i = 0; i < 5; i++) { + scanf_s("%d", &a[i]); + } + + int max = a[0]; + for (int i = 1; i < 5; i++) { + if (a[i] > max) { + max = a[i]; + } + } + printf("%d", max); + return max; +} + +/* +tests: +input | output +1 | +2 | +3 | +4 | +*/ +char* L3Z5() { + char* ans = ""; + int season; + + printf(" \n"); + printf("1) \n"); + printf("2) \n"); + printf("3) \n"); + printf("4) \n"); + + scanf_s("%d", &season); + + while (!(1 <= season && season <= 4)) { + printf(" \n"); + printf("1) \n"); + printf("2) \n"); + printf("3) \n"); + printf("4) \n"); + scanf_s("%d", &season); + } + + if (season == 1) { + ans = ""; + } + else if (season == 2) { + ans = ""; + } + else if (season == 3) { + ans = ""; + } + else { + ans = ""; + } + + printf("%s", ans); + + return ans; + +} + +/* +tests: +input | output +1 | +264000 | +3567904 | +*/ +char* L3Z6() { + float price; + char* ans = ""; + printf(" = "); + scanf_s("%f", &price); + if (price <= 250000) { + ans = ""; + } + else if (price > 250000 && price <= 700000) { + ans = ""; + } + else if (price > 700000 && price <= 1000000) { + ans = ""; + } + else if (price > 1000000 && price <= 100000000) { + ans = " "; + } + printf("%s", ans); + + return ans; +} + +/* +tests: +input | output +1 | +123 | +735 | +9090 | +*/ +char* L3Z7() { + float ms; + char* ans = ""; + + printf(" = "); + scanf_s("%f", &ms); + + if (ms <= 1) { + ans = ""; + } + else if (ms > 1 && ms <= 2) { + ans = " "; + } + else if (ms > 2 && ms <= 100) { + ans = ""; + } + else if (ms > 100 && ms <= 1000) { + ans = ""; + } + else if (ms > 1000 && ms <= 5000) { + ans = ""; + } + else if (ms > 5000 && ms <= 10000) { + ans = " "; + } + printf("%s", ans); + + return ans; +} \ No newline at end of file diff --git a/lab/lab4.c b/lab/lab4.c new file mode 100644 index 0000000..75d023a --- /dev/null +++ b/lab/lab4.c @@ -0,0 +1,130 @@ +#include +#include +#include +#include + +void L4Z1(), L4Z2(), L4Z3(), L4Z4(), L4Z5(), L4Z6(), L4Z7(); + +int main4() { + setlocale(LC_ALL, "RU"); + + //L4Z1(); + //L4Z2(); + //L4Z3(); + //L4Z4(); + //L4Z4(); + //L4Z5(); + //L4Z6(); + //L4Z7(); + + + return 0; +} + +void L4Z1() { + int n, i = 1; + + printf("n = "); + scanf_s("%d", &n); + + do { + printf("%d ", i); + i++; + } while (i <= n); +} + +void L4Z2() { + int n, stepen = 1, i = 0; + printf("n = "); + scanf_s("%d", &n); + + do { + printf("%d^%d = %d\n", n, i, stepen); + stepen *= n; + i++; + } while (i <= 5); +} + +void L4Z3() { + float summa, percent; + int i = 0; + + printf("summa = "); + scanf_s("%f", &summa); + + printf("percent = "); + scanf_s("%f", &percent); + + do { + printf("%2d year summa = %10.0f\n", i, summa); + summa *= (percent / 100 + 1); + i++; + } while (i <= 10); +} + +void L4Z4() { + int n, i = 1; + scanf_s("%d", &n); + + do { + printf("%d ", 2 * i); + i++; + } while (i <= n); +} + +void L4Z5() { + int n, a, i = 1; + scanf_s("%d", &n); + scanf_s("%d", &a); + + do { + printf("%d ", a * i); + i++; + } while (i <= n); +} + +void L4Z6() { + int i = 2; + int n; + scanf_s("%d", &n); + + do { + bool ok = true; + int del = 2; + + while (del < ((int)sqrt(i)) + 1) { + if ((i % del) == 0) { + ok = false; + break; + } + del++; + } + + /*for (int del = 2; del < ((int)sqrt(i)) + 1; del++) { + if ((i % del) == 0) { + ok = false; + break; + } + }*/ + + if (ok) { + printf("%d ", i); + n--; + } + i++; + } while (n > 0); +} + +void L4Z7() { + int summ, transh, n; + float percent; + summ = 1000000, transh = 1000000, n = 3, percent = 18; + printf("summ, transh, n, percent"); + scanf_s("%d%d%d%f", &summ, &transh, &n, &percent); + do { + summ = summ * (percent / 100 + 1) - transh; + n--; + } while (n > 0); + + printf("%d", summ); +} \ No newline at end of file diff --git a/window/L8.cpp b/window/L8.cpp new file mode 100644 index 0000000..5d589f7 --- /dev/null +++ b/window/L8.cpp @@ -0,0 +1,194 @@ +#include "L8.h" + +#define SIN(x) sin(M_PI*x/180) +#define COS(x) cos(M_PI*x/180) +#define ATAN(y,x) atan2f(y,x)/M_PI*180 +#define LLL(x,y) sqrt(pow(x,2) + pow(y,2)) + +void L8_christmas_tree(HDC hdc, int x, int y) { + +}; + +void L8_logo(HDC hdc, int x, int y) { + SelectObject(hdc, GetStockObject(NULL_PEN)); + SelectObject(hdc, CreateSolidBrush(RGB(0, 0, 0))); + + Ellipse(hdc, x, y, x + 150, y + 150); + + SelectObject(hdc, GetStockObject(DC_BRUSH)); + Ellipse(hdc, x + 30, y + 30, x + 120, y + 120); + + SelectObject(hdc, CreateSolidBrush(RGB(1, 99, 171))); + Pie(hdc, x + 30, y + 30, x + 120, y + 120, x + 75, y, x, y + 75); + Pie(hdc, x + 30, y + 30, x + 120, y + 120, x + 75, y + 120, x + 120, y + 75); + + SelectObject(hdc, GetStockObject(DC_BRUSH)); + SelectObject(hdc, CreatePen(BS_SOLID, 3, RGB(255, 255, 255))); + POINT M[5]; + M[0] = { x + 75 - 10,y + 30 - 5 }; + M[1] = { x + 75 - 10,y + 5 }; + M[2] = { x + 75,y + 15 }; + M[3] = { x + 75 + 10,y + 5 }; + M[4] = { x + 75 + 10,y + 30 - 5 }; + + /*for (int i = 0; i < 5; i++) { + float L = sqrt(pow(x + 75 - M[i].x, 2) + pow(y + 75 - M[i].y, 2)); + float ang = (float)ATAN(y + 75 - M[i].y, x + 75 - M[i].x) + 35; + M[i].x = x + 75 + (float)L * COS(ang); + M[i].y = y + 75 - (float)L * SIN(ang); + }*/ + Polyline(hdc, M, 5); + + int ALPHA = 35; + + POINT W[5]; + W[0] = { x + 75 - 10,y + 5 }; + W[1] = { x + 75 - 10,y + 30 - 5 }; + W[2] = { x + 75,y + 15 }; + W[3] = { x + 75 + 10,y + 30 - 5 }; + W[4] = { x + 75 + 10,y + 5 }; + + for (int i = 0; i < 5; i++) { + float L = sqrt(pow(x + 75 - W[i].x, 2) + pow(y + 75 - W[i].y, 2)); + float ang = (float)ATAN(y + 75 - W[i].y, x + 75 - W[i].x) - ALPHA; + W[i].x = x + 75 + (float)L * COS(ang); + W[i].y = y + 75 - (float)L * SIN(ang); + } + + Polyline(hdc, W, 5); + + POINT B[2]; + B[0] = { x + 75 - 10,y + 5 }; + B[1] = { x + 75 - 10,y + 30 - 5 }; + + int xc = x + 75, yc = y + 75; + int shag = 5; + + POINT Bprev = B[0]; + + for (int i = 0; i < 180; i += shag) { + float x2, y2; + float L1, ang1, L2, ang2; + + L1 = LLL(Bprev.x - xc, Bprev.y - yc); + ang1 = ATAN((Bprev.y-yc), (Bprev.x-xc)) - ALPHA; + + //MoveToEx(hdc, Bprev.x, Bprev.y, NULL); + + + x2 = (float)B[0].x + 20 * SIN((i + shag)); + y2 = (float)B[0].y + 5 - 5 * COS((i + shag)); + + L2 = LLL((x2 - xc), (y2 - yc)); + ang2 = ATAN((y2-yc), (x2-xc)) - ALPHA; + Bprev.x = x2; + Bprev.y = y2; + + + //LineTo(hdc, Bprev.x, Bprev.y); + + MoveToEx(hdc, xc + L1 * COS(ang1), yc + L1 * SIN(ang1), NULL); + LineTo(hdc, xc + L2 * COS(ang2), yc + L2 * SIN(ang2)); + } + + for (int i = 0; i < 180; i += shag) { + float x2, y2; + float L1, ang1, L2, ang2; + + L1 = LLL(Bprev.x - xc, Bprev.y - yc); + ang1 = ATAN((Bprev.y - yc), (Bprev.x - xc)) - ALPHA; + + //MoveToEx(hdc, Bprev.x, Bprev.y, NULL); + + + x2 = (float)B[0].x + 20 * SIN((i + shag)); + y2 = (float)B[0].y + 15 - 5 * COS((i + shag)); + + L2 = LLL((x2 - xc), (y2 - yc)); + ang2 = ATAN((y2 - yc), (x2 - xc)) - ALPHA; + Bprev.x = x2; + Bprev.y = y2; + + + //LineTo(hdc, Bprev.x, Bprev.y); + + MoveToEx(hdc, xc + L1 * COS(ang1), yc + L1 * SIN(ang1), NULL); + LineTo(hdc, xc + L2 * COS(ang2), yc + L2 * SIN(ang2)); + } + + + for (int i = 0; i < 2; i++) { + float L = LLL((xc - B[i].x), (yc - B[i].y)); + float ang = (float)ATAN((B[i].y - yc), (B[i].x - xc)) - ALPHA; + B[i].x = xc + (float)L * COS(ang); + B[i].y = yc + (float)L * SIN(ang); + } + + MoveToEx(hdc, B[0].x, B[0].y, NULL); + LineTo(hdc, B[1].x, B[1].y); + + /*for (int i = 0; i <= 180; i += 5) { + MoveToEx(hdc, Bprev.x, Bprev.y, NULL); + POINT Bend = { B[0].x + 20 * SIN(i), B[0].y + 15 - 5 * COS(i) }; + LineTo(hdc, Bend.x, Bend.y); + Bprev = { Bend.x,Bend.y }; + }*/ +} + +void StClausAuto(HDC hdc, int x, int y) { + MoveToEx(hdc, x+20, y, NULL); + LineTo(hdc, x+30, y+20); + LineTo(hdc, x+10, y+20); + LineTo(hdc, x+20, y); + + MoveToEx(hdc, x+20, y+10, NULL); + LineTo(hdc, x+30, y+40); + LineTo(hdc, x+10, y+40); + LineTo(hdc, x+20, y+10); + + MoveToEx(hdc, x+20, y+30, NULL); + LineTo(hdc, x+40, y+80); + LineTo(hdc, x, y+80); + LineTo(hdc, x+20, y+30); +} + +void pattern1(HDC hdc, void (*f)(HDC, int, int)) { + f(hdc, 0, 0); + + f(hdc, 625, 0); + + f(hdc, 300, 300); + + f(hdc, 0, 600); + + f(hdc, 625, 600); +}; + +void pattern2(HDC hdc, void (*f)(HDC, int, int)) { + int x = 0; + + while (x <= 625) { + f(hdc, x, 0); + x += 200; + } +}; + +void pattern3(HDC hdc, void (*f)(HDC, int, int)) { + int y = 0; + + while (y <= 625) { + f(hdc, 0, y); + y += 200; + } +}; + +void pattern4(HDC hdc, void (*f)(HDC, int, int)) { + int y = 0; + int x = 0; + + while (y <= 625) { + f(hdc, x, y); + y += 200; + x += 200; + } +}; \ No newline at end of file diff --git a/window/L8.h b/window/L8.h new file mode 100644 index 0000000..38cd7b2 --- /dev/null +++ b/window/L8.h @@ -0,0 +1,12 @@ +#pragma once + +#include +#define _USE_MATH_DEFINES +#include + +void L8_logo(HDC, int, int); +void pattern1(HDC, void (HDC, int, int)); +void pattern2(HDC, void (HDC, int, int)); +void pattern3(HDC, void (HDC, int, int)); +void pattern4(HDC, void (HDC, int, int)); +void StClausAuto(HDC, int, int); \ No newline at end of file diff --git a/window/Paint.cpp b/window/Paint.cpp new file mode 100644 index 0000000..4c66e3a --- /dev/null +++ b/window/Paint.cpp @@ -0,0 +1,506 @@ +#include "Paint.h" + +#define SIN(x) sin(M_PI*x/180) +#define COS(x) cos(M_PI*x/180) +#define ATAN(y,x) atan2f(y,x)/M_PI*180 + +void paint_figures(HDC hdc) { + int defaultxy = 20; + + int x1, y1; + int x2, y2; + + x1 = defaultxy, y1 = defaultxy; + x2 = defaultxy, y2 = defaultxy + 300; + + do { + MoveToEx(hdc, x1, y1, NULL); + LineTo(hdc, x2, y2); + y1 += 10; + x2 += 10; + } while (y1 <= defaultxy + 300); + + x1 = 2 * defaultxy + 300, y1 = defaultxy; + x2 = 2 * defaultxy + 300, y2 = defaultxy + 300; + + do { + MoveToEx(hdc, x1, y1, NULL); + LineTo(hdc, x2, y2); + x1 += 10; + x2 += 10; + y1 += 10; + y2 -= 10; + } while (x1 <= 2 * defaultxy + 2 * 300); + + + x1 = defaultxy, y1 = 2 * defaultxy + 300; + x2 = defaultxy, y2 = 2 * defaultxy + 2 * 300; + int r = 255, g = 0, b = 0; + int i = 1; + HPEN hPen; + + do { + hPen = CreatePen(PS_SOLID, 1, RGB(r, g, b)); + SelectObject(hdc, hPen); + MoveToEx(hdc, x1, y1, NULL); + LineTo(hdc, x2, y2); + DeleteObject(hPen); + x1 += 10; + x2 += 10; + y1 += 1; + y2 -= 1; + switch (i % 7) { + case 0: + r = 255, g = 0, b = 0; + break; + case 1: + r = 255, g = 165, b = 0; + break; + case 2: + r = 255, g = 255, b = 0; + break; + case 3: + r = 128, g = 255, b = 0; + break; + case 4: + r = 0, g = 191, b = 255; + break; + case 5: + r = 0, g = 0, b = 255; + break; + case 6: + r = 139, g = 0, b = 255; + break; + } + i++; + } while (x1 < defaultxy + 300); + + SelectObject(hdc, GetStockObject(DC_PEN)); + + x1 = 2 * defaultxy + 300, y1 = 2 * defaultxy + 300; + x2 = 2 * defaultxy + 300, y2 = 2 * defaultxy + 2 * 300; + + r = 255, g = 0, b = 0; + i = 1; + + do { + + hPen = CreatePen(PS_SOLID, 1, RGB(r, g, b)); + SelectObject(hdc, hPen); + MoveToEx(hdc, x1, y1, NULL); + LineTo(hdc, x2, y2); + DeleteObject(hPen); + + MoveToEx(hdc, x1, y1, NULL); + LineTo(hdc, x2, y2); + DeleteObject(hPen); + x2 += 10; + y1 += 10; + y2 -= 10; + + switch (i % 7) { + case 0: + r = 255, g = 0, b = 0; + break; + case 1: + r = 255, g = 165, b = 0; + break; + case 2: + r = 255, g = 255, b = 0; + break; + case 3: + r = 128, g = 255, b = 0; + break; + case 4: + r = 0, g = 191, b = 255; + break; + case 5: + r = 0, g = 0, b = 255; + break; + case 6: + r = 139, g = 0, b = 255; + break; + } + i++; + } while (y1 <= 2 * defaultxy + +2 * 300); + + SelectObject(hdc, GetStockObject(DC_BRUSH)); + SelectObject(hdc, GetStockObject(DC_PEN)); +} + +void house(HDC hdc, int xstart, int ystart) { + HPEN HPen; + + HPen = CreatePen(PS_SOLID, 2, RGB(0, 0, 0)); + SelectObject(hdc, HPen); + POINT pt[5]; + pt[0] = { xstart + 150, ystart }; + pt[1] = { xstart + 300, ystart + 100 }; + pt[2] = { xstart + 300, ystart + 300 }; + pt[3] = { xstart, ystart + 300 }; + pt[4] = { xstart, ystart + 100 }; + Polygon(hdc, pt, 5); + + MoveToEx(hdc, pt[1].x, pt[1].y, NULL); + LineTo(hdc, pt[4].x, pt[4].y); + + Rectangle(hdc, pt[4].x + 75, pt[4].y + 50, pt[2].x - 75, pt[2].y - 50); + + MoveToEx(hdc, xstart + 150, ystart + 150, NULL); + LineTo(hdc, xstart + 150, ystart + 250); + + MoveToEx(hdc, xstart + 150, ystart + 200, NULL); + LineTo(hdc, xstart + 225, ystart + 200); + + DeleteObject(HPen); + SelectObject(hdc, GetStockObject(DC_PEN)); +} + +void oldhouse(HDC hdc) { + POINT pt[5]; + pt[0].x = 250; + pt[0].y = 100; + pt[1].x = 400; + pt[1].y = 200; + pt[2].x = 400; + pt[2].y = 400; + pt[3].x = 100; + pt[3].y = 400; + pt[4].x = 100; + pt[4].y = 200; + + MoveToEx(hdc, pt[0].x, pt[0].y, NULL); + for (int i = 1; i < 5; i++) { + LineTo(hdc, pt[i].x, pt[i].y); + } + LineTo(hdc, pt[0].x, pt[0].y); + + MoveToEx(hdc, pt[1].x, pt[1].y, NULL); + LineTo(hdc, pt[4].x, pt[4].y); + + int marginWindow = 56; + + marginWindow = marginWindow % ((pt[1].y - pt[2].y) / 2); + + POINT ptwindow[5]; + ptwindow[0].x = pt[1].x - marginWindow; + ptwindow[0].y = pt[1].y + marginWindow; + ptwindow[1].x = pt[2].x - marginWindow; + ptwindow[1].y = pt[2].y - marginWindow; + ptwindow[2].x = pt[3].x + marginWindow; + ptwindow[2].y = pt[3].y - marginWindow; + ptwindow[3].x = pt[4].x + marginWindow; + ptwindow[3].y = pt[4].y + marginWindow; + ptwindow[4].x = pt[1].x - marginWindow; + ptwindow[4].y = pt[1].y + marginWindow; + + Polyline(hdc, ptwindow, 5); + + int centerx = pt[4].x + (pt[1].x - pt[4].x) / 2; + int centery = pt[1].y + (pt[2].y - pt[1].y) / 2; + + MoveToEx(hdc, centerx, ptwindow[0].y, NULL); + LineTo(hdc, centerx, ptwindow[1].y); + + MoveToEx(hdc, centerx, centery, NULL); + LineTo(hdc, ptwindow[0].x, centery); +} + +void car(HDC hdc, int xstart, int ystart, COLORREF color) { + HBRUSH HBrush; + HBrush = CreateSolidBrush(color); + SelectObject(hdc, HBrush); + Rectangle(hdc, xstart, ystart + 50, xstart + 250, ystart + 100); + DeleteObject(HBrush); + SelectObject(hdc, GetStockObject(DC_BRUSH)); + + HBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(0, 0, 0)); + SelectObject(hdc, HBrush); + Ellipse(hdc, xstart + 25, ystart + 75, xstart + 75, ystart + 125); + Ellipse(hdc, xstart + 175, ystart + 75, xstart + 225, ystart + 125); + DeleteObject(HBrush); + SelectObject(hdc, GetStockObject(DC_BRUSH)); + + POINT pt[4]; + pt[0] = { xstart + 50, ystart + 50 }; + pt[1] = { xstart + 100, ystart }; + pt[2] = { xstart + 200, ystart }; + pt[3] = { xstart + 250, ystart + 50 }; + Polyline(hdc, pt, 4); + + MoveToEx(hdc, pt[1].x, pt[1].y, NULL); + LineTo(hdc, pt[1].x, pt[1].y + 50); + + MoveToEx(hdc, pt[2].x, pt[2].y, NULL); + LineTo(hdc, pt[2].x, pt[2].y + 50); +} + +void carD(HDC hdc, int xstart, int ystart) { + car(hdc, xstart, ystart, RGB(0, 255, 255)); + +} + +void bush1(HDC hdc, int xstart, int ystart, COLORREF color) { + HPEN HPen; + HPen = CreatePen(PS_SOLID, 2, color); + SelectObject(hdc, HPen); + + POINT end = { xstart - 75,ystart - 75 }; + + while (end.x <= xstart + 75) { + MoveToEx(hdc, xstart, ystart, NULL); + LineTo(hdc, end.x, end.y); + end.x += 15; + } + + DeleteObject(HPen); + SelectObject(hdc, GetStockObject(DC_PEN)); +} + +void bush2(HDC hdc, int xstart, int ystart, COLORREF color) { + HPEN HPen; + HPen = CreatePen(PS_SOLID, 2, color); + SelectObject(hdc, HPen); + + POINT end = { -100,0 }; + + while (end.x <= 0) { + MoveToEx(hdc, xstart, ystart, NULL); + LineTo(hdc, xstart + end.x, ystart - end.y); + end.x += 10; + end.y += 20; + } + + end.x -= 10; + end.y -= 20; + + while (end.x <= 100) { + MoveToEx(hdc, xstart, ystart, NULL); + LineTo(hdc, xstart + end.x, ystart - end.y); + end.x += 10; + end.y -= 20; + } + + DeleteObject(HPen); + SelectObject(hdc, GetStockObject(DC_PEN)); + + DeleteObject(HPen); + SelectObject(hdc, GetStockObject(DC_PEN)); +} + +void christmasTree(HDC hdc, int xstart, int ystart) { + HBRUSH HBrush; + + HBrush = CreateSolidBrush(RGB(0, 255, 0)); + SelectObject(hdc, HBrush); + POINT pt[3]; + pt[0] = { xstart + 50, ystart }; + pt[1] = { xstart + 100, ystart + 50 }; + pt[2] = { xstart, ystart + 50 }; + + int diff = 50; + Polygon(hdc, pt, 3); + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 3; j++) { + pt[j].y += diff; + } + Polygon(hdc, pt, 3); + } + DeleteObject(HBrush); + + HBrush = CreateSolidBrush(RGB(88, 57, 39)); + SelectObject(hdc, HBrush); + Rectangle(hdc, pt[2].x + 37, pt[2].y, pt[1].x - 37, pt[1].y + 25); + DeleteObject(HBrush); + SelectObject(hdc, GetStockObject(DC_BRUSH)); +} + +void tree(HDC hdc, int xstart, int ystart) { + HBRUSH HBrush; + + HBrush = CreateSolidBrush(RGB(88, 57, 39)); + SelectObject(hdc, HBrush); + Rectangle(hdc, xstart + 37, ystart + 115, xstart + 63, ystart + 200); + DeleteObject(HBrush); + + HBrush = CreateSolidBrush(RGB(0, 255, 0)); + SelectObject(hdc, HBrush); + Ellipse(hdc, xstart, ystart, xstart + 100, ystart + 125); + DeleteObject(HBrush); + SelectObject(hdc, GetStockObject(DC_BRUSH)); +} + +void treeR(HDC hdc, int xstart, int ystart, int ang) { + HBRUSH HBrush; + + HBrush = CreateSolidBrush(RGB(88, 57, 39)); + SelectObject(hdc, HBrush); + POINT pt[4]; + pt[0] = { xstart, ystart }; + pt[1] = { (long)(xstart + (float)25 * COS(ang)), (long)(ystart + (float)25 * SIN(ang)) }; + pt[2] = { (long)(xstart + (float)25 * COS(ang) - (float)85 * SIN(ang)), (long)(ystart + (float)85 * COS(ang) + (float)25 * SIN(ang)) }; + pt[3] = { (long)(xstart - (float)85 * SIN(ang)), (long)(ystart + (float)85 * COS(ang)) }; + + Polygon(hdc, pt, 4); + DeleteObject(HBrush); + + DeleteObject(HBrush); + SelectObject(hdc, GetStockObject(DC_BRUSH)); +} + +void test(HDC hdc, int xcenter, int ycenter, int width, int heigth, int ang) { + + float R1 = (float)(width / 2), R2 = (float)(heigth / 2); + + float downX = (float)width * COS(ang) - (float)heigth * SIN(ang); + float downY = (float)heigth * COS(ang) + (float)width * SIN(ang); + + + POINT pt[4]; + pt[0] = { (long)(xcenter - downX / 2), (long)(ycenter - downY / 2) }; + pt[1] = { (long)(pt[0].x + (float)width * COS(ang)), (long)(pt[0].y + (float)width * SIN(ang)) }; + pt[2] = { (long)(pt[0].x + downX), (long)(pt[0].y + downY) }; + pt[3] = { (long)(pt[0].x - (float)heigth * SIN(ang)), (long)(pt[0].y + (float)heigth * COS(ang)) }; + + Polygon(hdc, pt, 4); + + float shag = 5; + + float i = 0; + + while (i < 360) { + float x1, y1, L1, ang1, x2, y2, L2, ang2, res; + + x1 = R1 + (float)(R1 * COS(i)); + y1 = R2 - (float)(R2 * SIN(i)); + #ifdef TEST + MoveToEx(hdc, (int)x1, (int)y1, NULL); + #endif + + + L1 = sqrt(pow(x1, 2) + pow(y1, 2)); + ang1 = ATAN(y1, x1); + res = (ang1 + ang); + x1 = xcenter + L1 * COS(res) - downX / 2; + y1 = ycenter + L1 * SIN(res) - downY / 2; + + i += shag; + + if (i > 360) i = 360; + + x2 = R1 + (float)(R1 * COS(i)); + y2 = R2 - (float)(R2 * SIN(i)); + #ifdef TEST + LineTo(hdc, (int)x2, (int)y2); + #endif + L2 = sqrt(pow(x2, 2) + pow(y2, 2)); + ang2 = ATAN(y2, x2); + res = (ang2 + ang); + x2 = xcenter + L2 * COS(res) - downX / 2; + y2 = ycenter + L2 * SIN(res) - downY / 2; + MoveToEx(hdc, (int)x1, (int)y1, NULL); + LineTo(hdc, (int)x2, (int)y2); + } + + MoveToEx(hdc, xcenter, ycenter + heigth, NULL); + LineTo(hdc, xcenter, ycenter - heigth); + + MoveToEx(hdc, xcenter + width, ycenter, NULL); + LineTo(hdc, xcenter - width, ycenter); +} + +void sun(HDC hdc, int xcenter, int ycenter) { + HBRUSH HBrush; + HPEN HPen; + + HBrush = CreateSolidBrush(RGB(255, 255, 0)); + HPen = CreatePen(PS_SOLID, 2, RGB(255, 255, 0)); + SelectObject(hdc, HBrush); + SelectObject(hdc, HPen); + Ellipse(hdc, xcenter - 50, ycenter - 50, xcenter + 50, ycenter + 50); + + + int margin = 60; + int length = 100; + int n = 14.88; + float shag = (float)90 / (n - 1); + + for (float i = 0; i < 360; i += shag) { + double alph = i / 180 * M_PI; + double S = sin(alph); + double C = cos(alph); + int ystart = margin * S, + yend = ystart + length * S, + xstart = margin * C, + xend = xstart + length * C; + + MoveToEx(hdc, xcenter - xstart, ycenter + ystart, NULL); + LineTo(hdc, xcenter - xend, ycenter + yend); + } + + // + + //margin = 360, length = 100; + + //for (double i = 0; i < 360; i += 10) { + // double alph = (double)i / 180 * M_PI; + // double S = sin(alph) / 4; + // double C = cos(alph) / 5; + // int ystart = margin * S, + // yend = ystart + length * 5 * S, + // xstart = margin * C, + // xend = (xstart + length * 4 * C); + + // MoveToEx(hdc, 400 - xstart, 400 + ystart, NULL); + // LineTo(hdc, 400 - xend, 400 + yend); + //} + + //margin = sqrt(60), length = 10; + + //for (double i = 0; i < 360; i += 10) { + // double alph = (double)i / 180 * M_PI; + // double S = sin(alph); + // double C = cos(alph); + // double ystart = margin * S * 5, + // yend = ystart + length * S * 5, + // xstart = margin * C * 4, + // xend = xstart + length * C * 4; + + // MoveToEx(hdc, 400 - (int)xstart, 400 + (int)ystart, NULL); + // LineTo(hdc, 400 - (int)xend, 400 + (int)yend); + //} + + //int R = 360; + + //for (double i = 0; i < 360; i += .1) { + // double alph = (double)i / 180 * M_PI; + // double S = sin(alph) / 4; + // double C = cos(alph) / 5; + + // double alph1 = (double)(i + 0.1) / 180 * M_PI; + // double S1 = sin(alph1) / 4; + // double C1 = cos(alph1) / 5; + + // int ystart = (R * S), + // yend = (R * S1), + // xstart = (R * C), + // xend = (R * C1); + + // MoveToEx(hdc, 400 - xstart, 400 + ystart, NULL); + // LineTo(hdc, 400 - xend, 400 + yend); + + // ystart = (R+500) * S, + // yend = (R+500) * S1, + // xstart = (R+400) * C, + // xend = (R+400) * C1; + + // MoveToEx(hdc, 400 - xstart, 400 + ystart, NULL); + // LineTo(hdc, 400 - xend, 400 + yend); + //} + + DeleteObject(HBrush); + DeleteObject(HPen); + + SelectObject(hdc, GetStockObject(DC_BRUSH)); + SelectObject(hdc, GetStockObject(DC_PEN)); +} \ No newline at end of file diff --git a/window/Paint.h b/window/Paint.h new file mode 100644 index 0000000..b6b6c53 --- /dev/null +++ b/window/Paint.h @@ -0,0 +1,18 @@ +#pragma once + +#include +#define _USE_MATH_DEFINES +#include + +void paint_figures(HDC hdc); +void house(HDC hdc, int xstart, int ystart); +void oldhouse(HDC hdc); +void car(HDC hdc, int xstart, int ystart, COLORREF color); +void carD(HDC hdc, int xstart, int ystar); +void bush1(HDC hdc, int xstart, int ystart, COLORREF color); +void bush2(HDC hdc, int xstart, int ystart, COLORREF color); +void christmasTree(HDC hdc, int xstart, int ystart); +void tree(HDC hdc, int xstart, int ystart); +void treeR(HDC hdc, int xstart, int ystart, int ang); +void test(HDC hdc, int xcenter, int ycenter, int width, int heigth, int ang); +void sun(HDC hdc, int xcenter, int ycenter); \ No newline at end of file diff --git a/window/desktop.ini b/window/desktop.ini new file mode 100644 index 0000000..7c48ef4 --- /dev/null +++ b/window/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26 diff --git a/window/framework.h b/window/framework.h new file mode 100644 index 0000000..a8f6dc8 --- /dev/null +++ b/window/framework.h @@ -0,0 +1,15 @@ +// header.h: включаемый файл для стандартных системных включаемых файлов +// или включаемые файлы для конкретного проекта +// + +#pragma once + +#include "targetver.h" +#define WIN32_LEAN_AND_MEAN // Исключите редко используемые компоненты из заголовков Windows +// Файлы заголовков Windows +#include +// Файлы заголовков среды выполнения C +#include +#include +#include +#include diff --git a/window/resource.h b/window/resource.h new file mode 100644 index 0000000..33f2cc3 --- /dev/null +++ b/window/resource.h @@ -0,0 +1,34 @@ +//{{NO_DEPENDENCIES}} +// Включаемый файл, созданный в Microsoft Visual C++. +// Используется window.rc +// +#define IDC_MYICON 2 +#define IDD_WINDOW_DIALOG 102 +#define IDS_APP_TITLE 103 +#define IDD_ABOUTBOX 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDI_WINDOW 107 +#define IDI_SMALL 108 +#define IDC_WINDOW 109 +#define IDR_MAINFRAME 128 +#define WRITE_HOME 32771 +#define ID_32772 32772 +#define CLEAR_WINDOW 32773 +#define CLEAR_WINDOW_MY 32774 +#define ID_32775 32775 +#define WRITE_FIGURE 32776 +#define ID_32777 32777 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32778 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/window/small.ico b/window/small.ico new file mode 100644 index 0000000..b3ec03b Binary files /dev/null and b/window/small.ico differ diff --git a/window/targetver.h b/window/targetver.h new file mode 100644 index 0000000..d90003d --- /dev/null +++ b/window/targetver.h @@ -0,0 +1,6 @@ +#pragma once + +// // При включении SDKDDKVer.h будет задана самая новая из доступных платформ Windows. +// Если вы планируете сборку приложения для предыдущей версии платформы Windows, включите WinSDKVer.h и +// задайте желаемую платформу в макросе _WIN32_WINNT, прежде чем включать SDKDDKVer.h. +#include diff --git a/window/window.cpp b/window/window.cpp new file mode 100644 index 0000000..c3123b4 --- /dev/null +++ b/window/window.cpp @@ -0,0 +1,316 @@ +// window.cpp : Определяет точку входа для приложения. +// + +#include "framework.h" +#include "window.h" +#define _USE_MATH_DEFINES +//#define DEBUG_GAME +#include +#include + +//#define TEST +//#define FIRST + +#define SEVEN +#include "Paint.h" + +#include "L8.h" + + + +#define MAX_LOADSTRING 100 +#define Draw 1023 + +// Глобальные переменные: +HINSTANCE hInst; // текущий экземпляр +WCHAR szTitle[MAX_LOADSTRING]; // Текст строки заголовка +WCHAR szWindowClass[MAX_LOADSTRING]; // имя класса главного окна + +// Отправить объявления функций, включенных в этот модуль кода: +ATOM MyRegisterClass(HINSTANCE hInstance); +BOOL InitInstance(HINSTANCE, int); +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); + +int sost = 1; +int MyX = 0, MyY = 0, MyAng = 0; + +int APIENTRY wWinMain(_In_ HINSTANCE hInstance, + _In_opt_ HINSTANCE hPrevInstance, + _In_ LPWSTR lpCmdLine, + _In_ int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + + // TODO: Разместите код здесь. + + // Инициализация глобальных строк + LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + LoadStringW(hInstance, IDC_WINDOW, szWindowClass, MAX_LOADSTRING); + MyRegisterClass(hInstance); + + // Выполнить инициализацию приложения: + if (!InitInstance (hInstance, nCmdShow)) + { + return FALSE; + } + + HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WINDOW)); + + MSG msg; + + // Цикл основного сообщения: + while (GetMessage(&msg, nullptr, 0, 0)) + { + if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + return (int) msg.wParam; +} + + + +// +// ФУНКЦИЯ: MyRegisterClass() +// +// ЦЕЛЬ: Регистрирует класс окна. +// +ATOM MyRegisterClass(HINSTANCE hInstance) +{ + WNDCLASSEXW wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WINDOW)); + wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_WINDOW); + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); + + return RegisterClassExW(&wcex); +} + +// +// ФУНКЦИЯ: InitInstance(HINSTANCE, int) +// +// ЦЕЛЬ: Сохраняет маркер экземпляра и создает главное окно +// +// КОММЕНТАРИИ: +// +// В этой функции маркер экземпляра сохраняется в глобальной переменной, а также +// создается и выводится главное окно программы. +// +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + hInst = hInstance; // Сохранить маркер экземпляра в глобальной переменной + + HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, + 20, 20, 800, 800, nullptr, nullptr, hInstance, nullptr); + + if (!hWnd) + { + return FALSE; + } + + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + return TRUE; +} + + + +// +// ФУНКЦИЯ: WndProc(HWND, UINT, WPARAM, LPARAM) +// +// ЦЕЛЬ: Обрабатывает сообщения в главном окне. +// +// WM_COMMAND - обработать меню приложения +// WM_PAINT - Отрисовка главного окна +// WM_DESTROY - отправить сообщение о выходе и вернуться +// +// +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_COMMAND: + { + int wmId = LOWORD(wParam); + // Разобрать выбор в меню: + switch (wmId) + { + case WRITE_HOME: + sost = 1; + RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE); + break; + case WRITE_FIGURE: + sost = 2; + RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE); + break; + case CLEAR_WINDOW: + sost = 0; + RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE); + break; + case IDM_EXIT: + DestroyWindow(hWnd); + break; + //case Draw: + // sost = 1; + // RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE); + // break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + } + break; + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdc = BeginPaint(hWnd, &ps); + // TODO: Добавьте сюда любой код прорисовки, использующий HDC... + + //paint_figures(hdc); + + #ifdef FIRST + #ifndef SEVEN + if (abs(sost) % 3 == 1) { + house(hdc, 150, 75); + + car(hdc, 150, 445, RGB(0, 0, 255)); + car(hdc, 150, 600, RGB(0, 0, 0)); + christmasTree(hdc, 450, 350); + tree(hdc, 50, 350); + + bush1(hdc, 125, 125, RGB(0, 225, 0)); + bush2(hdc, 650, 650, RGB(127, 127, 127)); + + sun(hdc, 780, 0); + } + else if (abs(sost) % 3 == 2) { + paint_figures(hdc); + } + else { + //HWND Draw_BTN = CreateWindow(L"button", // Predefined class; Unicode assumed + // L"aSd", // Button text + // WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // Styles + // 10, // x position + // 10, // y position + // 100, // Button width + // 100, // Button height + // hWnd, // Parent window + // (HMENU) Draw, // No menu. + // NULL, + // NULL); + } + #endif + #ifdef SEVEN + switch (abs(sost)%7) { + case 0: + house(hdc, 150, 75); + break; + case 1: + car(hdc, 150, 445, RGB(0, 0, 255)); + break; + case 2: + christmasTree(hdc, 450, 350); + break; + case 3: + tree(hdc, 50, 350); + break; + case 4: + bush1(hdc, 125, 125, RGB(0, 225, 0)); + break; + case 5: + bush2(hdc, 650, 650, RGB(127, 127, 127)); + break; + case 6: + paint_figures(hdc); + break; + } + #endif + test(hdc, MyX + 400, MyY + 400, 50, 100, MyAng); + #endif + + + + #ifndef FIRST + void (*f)(HDC, int, int) = L8_logo; + switch (abs(sost) % 4){ + case 0: + pattern1(hdc, (*f)); + break; + case 1: + pattern2(hdc, (*f)); + break; + case 2: + pattern3(hdc, (*f)); + break; + case 3: + pattern4(hdc, (*f)); + break; + default: + break; + } + #endif + + + EndPaint(hWnd, &ps); + } + break; + case WM_CHAR: + switch (wParam) { + case 'a': + MyX -= 1; + break; + case 'd': + MyX += 1; + break; + case 'w': + MyY -= 1; + break; + case 's': + MyY += 1; + break; + case 'e': + MyAng += 1; + break; + case 'q': + MyAng -= 1; + break; + } + + InvalidateRect(hWnd, NULL, TRUE); + break; + case WM_KEYDOWN: + switch (wParam) { + case VK_RIGHT: + sost += 1; + break; + case VK_LEFT: + sost -= 1; + break; + default: + break; + } + RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE); + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} diff --git a/window/window.h b/window/window.h new file mode 100644 index 0000000..b798bf5 --- /dev/null +++ b/window/window.h @@ -0,0 +1,3 @@ +#pragma once + +#include "resource.h" diff --git a/window/window.ico b/window/window.ico new file mode 100644 index 0000000..b3ec03b Binary files /dev/null and b/window/window.ico differ diff --git a/window/window.rc b/window/window.rc new file mode 100644 index 0000000..6928b0c Binary files /dev/null and b/window/window.rc differ diff --git a/window/window.vcxproj b/window/window.vcxproj new file mode 100644 index 0000000..742da3d --- /dev/null +++ b/window/window.vcxproj @@ -0,0 +1,152 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {6df1e650-4412-4ce1-a5db-7d0a3c2eb2ec} + window + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Level3 + true + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/window/window.vcxproj.filters b/window/window.vcxproj.filters new file mode 100644 index 0000000..bbd116d --- /dev/null +++ b/window/window.vcxproj.filters @@ -0,0 +1,61 @@ + + + + + {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