diff --git a/exam test variant/exam test variant/exam test variant.vcxproj b/exam test variant/exam test variant/exam test variant.vcxproj
index 4d3aa87..e69997a 100644
--- a/exam test variant/exam test variant/exam test variant.vcxproj
+++ b/exam test variant/exam test variant/exam test variant.vcxproj
@@ -44,6 +44,7 @@
true
v143
Unicode
+ true
Application
@@ -51,6 +52,7 @@
v143
true
Unicode
+ false
diff --git a/exam test variant/exam test variant/main.c b/exam test variant/exam test variant/main.c
index b70aaed..abdba6a 100644
--- a/exam test variant/exam test variant/main.c
+++ b/exam test variant/exam test variant/main.c
@@ -2,6 +2,10 @@
#include
#include
+/*
+ * AddressSanitizer /
+ */
+
int N1;
int N2;
int M2;
@@ -202,6 +206,51 @@ void task3() {
printf("> 3\n");
}
+int countRow(int* buf, int len, int target)
+{
+ int count = 0;
+ for (int i = 0; i < len; i++) {
+ if (buf[i] == target) {
+ count += 1;
+ }
+ }
+ return 0;
+}
+
+int countColumn(int num, int column)
+{
+ int count = 0;
+ for (int n = 0; n < N2; n++) {
+ if (A2[n][column] == num) {
+ count += 1;
+ }
+ }
+ return count;
+}
+
+//
+void taskAnton()
+{
+ for (int m = 0; m < M2; m++) {
+ for (int n = 0; n < N2; n++) {
+ if (countColumn(A2[n][m], m) > 1) {
+ deleteColumn(m);
+ m -= 1;
+ break;
+ }
+ }
+ }
+ printf("> \n");
+}
+
+void print1D(int* buf, int len)
+{
+ for (int i = 0; i < len; i++) {
+ printf("%d ", buf[i]);
+ }
+ printf("\n");
+}
+
int main()
{
SetConsoleCP(1251);
@@ -209,13 +258,19 @@ int main()
loadLists("test1.txt");
printLists();
-
- task2();
- task3();
+
+ //task2();
+ //task3();
+ taskAnton();
printLists();
+ //print1D(A2[1], M2);
saveLists("out.txt");
+ while (1) {
+
+ }
+
return 0;
}
\ No newline at end of file
diff --git a/exam test variant/exam test variant/out.txt b/exam test variant/exam test variant/out.txt
index 65a0b5c..6574c8c 100644
--- a/exam test variant/exam test variant/out.txt
+++ b/exam test variant/exam test variant/out.txt
@@ -1,5 +1,10 @@
6
-1 2 104 106 7 8
-2 4
-6 4 5 1
-2 3 4 3
+1 2 4 6 7 8
+7 2
+-2 1
+3 6
+6 10
+10 -11
+9 3
+2 -1
+5 -8
diff --git a/exam test variant/exam test variant/test1.txt b/exam test variant/exam test variant/test1.txt
index bdc8364..6983486 100644
--- a/exam test variant/exam test variant/test1.txt
+++ b/exam test variant/exam test variant/test1.txt
@@ -1,10 +1,10 @@
6
1 2 4 6 7 8
7 4
--2 -1 0 1
-3 4 -5 6
-6 4 5 1
-10 -1 0 1
-2 3 4 3
+-2 1 0 1
+3 8 -5 6
+6 -4 5 10
+10 -1 0 -11
+9 3 4 3
2 1 0 -1
5 -6 7 -8
\ No newline at end of file
diff --git a/lab14/lab14/main.c b/lab14/lab14/main.c
index 3e41d2b..4a70a98 100644
--- a/lab14/lab14/main.c
+++ b/lab14/lab14/main.c
@@ -1,218 +1,218 @@
-#include
-#include
-
-
-int index(int num, int arr[], int len) {
- for (int i = 0; i < len; i++) {
- if (arr[i] == num) return i;
- }
- return -1;
-}
-
-int count(int num, int arr[], int len) {
- int count = 0;
- for (int i = 0; i < len; i++) {
- if (arr[i] == num) count += 1;
- }
- return count;
-}
-
-int arrmax(int arr[], int len) {
- int max = arr[0];
- for (int i = 1; i < len; i++) {
- if (arr[i] > max) max = arr[i];
- }
- return max;
-}
-
-int arrmin(int arr[], int len) {
- int min = arr[0];
- for (int i = 1; i < len; i++) {
- if (arr[i] < min) min = arr[i];
- }
- return min;
-}
-
-void printarr(int arr[], int len) {
- printf("[");
- for (int i = 0; i < len; i++) {
- printf("%d, ", arr[i]);
- }
- printf("\b\b]\n");
-}
-
-void deleteindex(int index, int arr[], int* len) {
- arr[index] = 0;
- for (int i = index; i < *len - 1; i++) {
- arr[i] = arr[i + 1];
- }
- *len -= 1;
-}
-
-void insert(int num, int index, int arr[], int* len) {
- for (int i = *len; i > index; i--) {
- arr[i] = arr[i - 1];
- }
- *len += 1;
- arr[index] = num;
-}
-
-void deletemax3(int arr[], int* len) {
- int max = arr[0];
- int maxi = 0;
- for (int i = 1; i < *len; i++) {
- if (arr[i] > max && arr[i] % 3 == 0) {
- max = arr[i];
- maxi = i;
- }
- }
- deleteindex(maxi, arr, len);
-}
-
-exchange_max_chains(int A[], int B[], int* sA, int* sB) {
- int a = A[0], sa = 1, ai = 0;
- int b = B[0], sb = 1, bi = 0;
- int ts = 1;
- for (int i = 0; i < *sA - 1; i++) {
- if (A[i] == A[i + 1]) {
- ts += 1;
- }
- else if (ts > sa) {
- sa = ts;
- ai = i + 1 - sa;
- ts = 1;
- a = A[i];
- }
- }
- ts = 1;
- for (int i = 0; i < *sB - 1; i++) {
- if (B[i] == B[i + 1]) {
- ts += 1;
- }
- else if (ts > sb) {
- sb = ts;
- bi = i + 1 - sb;
- ts = 1;
- b = B[i];
- }
- }
- for (int i = 0; i < sa; i++) {
- deleteindex(ai, A, sA);
- }
- for (int i = 0; i < sb; i++) {
- insert(b, ai, A, sA);
- }
- for (int i = 0; i < sb; i++) {
- deleteindex(bi, B, sB);
- }
- for (int i = 0; i < sa; i++) {
- insert(a, bi, B, sB);
- }
- printf("A: %d %d %d\n", a, sa, ai);
- printf("B: %d %d %d\n", b, sb, bi);
- printf("A = ");
- printarr(A, *sA);
- printf("B = ");
- printarr(B, *sB);
-}
-
-//#define ARRLEN 10
-
-int main() {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
-
- int arr[20] = { 3, 7, 12, 3, 4, 8, -1, 6, 1, 7 };
- int size = 10;
- int A[20] = {3, 2, 2, 5, 2, 1, 1, 1, 3, 9};
- int sA = 10;
- int B[20] = {1, 2, 5, 5, 4, 8, 3, 3};
- int sB = 8;
- int id, val;
-
- int n = 0;
- do {
- puts("\n");
- printf(" : ");
- printarr(arr, size);
- puts(" ");
- puts("1) ");
- puts("2) ");
- puts("3) ");
- puts("4) 0");
- puts("5) ");
- puts("6) ");
- puts("7) , ");
- puts("99) ");
- puts("10) , ");
- puts("11) A B ");
- puts("");
- puts("0) exit program");
-
- while (scanf_s(" %d", &n) != 1) {
- scanf_s("%*[^\n]");
- scanf_s("%*c");
- }
- puts("");
-
- switch (n)
- {
- case 1:
- printf("delete index = ");
- scanf_s("%d", &id);
- deleteindex(id, arr, &size);
- break;
- case 2:
- printf("value = ");
- scanf_s("%d", &val);
- printf("index = ");
- scanf_s("%d", &id);
- insert(val, id, arr, &size);
- break;
- case 3:
- deleteindex(index(arrmin(arr, size), arr, size), arr, &size);
- break;
- case 4:
- insert(0, index(arrmin(arr, size), arr, size), arr, &size);
- break;
- case 5:
- for (int i = 0; i < size; i++) {
- if (arr[i] % 2 == 0) deleteindex(i, arr, &size);
- }
- break;
- case 6:
- for (int i = 0; i < size; i++) {
- if (arr[i] % 2 == 0) {
- insert(arr[i], i, arr, &size);
- i += 2;
- }
- }
- break;
- case 7:
- insert(arrmin(arr, size), 0, arr, &size);
- break;
- case 99:
- deletemax3(arr, &size);
- break;
- case 10:
- for (int i = 0; i < size; i++) {
- if (count(arr[i], arr, size) == 1) {
- deleteindex(index(arr[i], arr, size), arr, &size);
- i -= 1;
- }
- }
- break;
- case 11:
- exchange_max_chains(A, B, &sA, &sB);
- break;
- case 0:
- puts("goodbye :3");
- break;
- default:
- puts("error: wrong N");
- break;
- }
-
- } while (n != 0);
- return 0;
-}
+#include
+#include
+
+
+int index(int num, int arr[], int len) {
+ for (int i = 0; i < len; i++) {
+ if (arr[i] == num) return i;
+ }
+ return -1;
+}
+
+int count(int num, int arr[], int len) {
+ int count = 0;
+ for (int i = 0; i < len; i++) {
+ if (arr[i] == num) count += 1;
+ }
+ return count;
+}
+
+int arrmax(int arr[], int len) {
+ int max = arr[0];
+ for (int i = 1; i < len; i++) {
+ if (arr[i] > max) max = arr[i];
+ }
+ return max;
+}
+
+int arrmin(int arr[], int len) {
+ int min = arr[0];
+ for (int i = 1; i < len; i++) {
+ if (arr[i] < min) min = arr[i];
+ }
+ return min;
+}
+
+void printarr(int arr[], int len) {
+ printf("[");
+ for (int i = 0; i < len; i++) {
+ printf("%d, ", arr[i]);
+ }
+ printf("\b\b]\n");
+}
+
+void deleteindex(int index, int arr[], int* len) {
+ arr[index] = 0;
+ for (int i = index; i < *len - 1; i++) {
+ arr[i] = arr[i + 1];
+ }
+ *len -= 1;
+}
+
+void insert(int num, int index, int arr[], int* len) {
+ for (int i = *len; i > index; i--) {
+ arr[i] = arr[i - 1];
+ }
+ *len += 1;
+ arr[index] = num;
+}
+
+exchange_max_chains(int A[], int B[], int* sA, int* sB) {
+ int a = A[0], sa = 1, ai = 0;
+ int b = B[0], sb = 1, bi = 0;
+ int ts = 1;
+ for (int i = 0; i < *sA - 1; i++) {
+ if (A[i] == A[i + 1]) {
+ ts += 1;
+ }
+ else if (ts > sa) {
+ sa = ts;
+ ai = i + 1 - sa;
+ ts = 1;
+ a = A[i];
+ }
+ }
+ ts = 1;
+ for (int i = 0; i < *sB - 1; i++) {
+ if (B[i] == B[i + 1]) {
+ ts += 1;
+ }
+ else if (ts > sb) {
+ sb = ts;
+ bi = i + 1 - sb;
+ ts = 1;
+ b = B[i];
+ }
+ }
+ for (int i = 0; i < sa; i++) {
+ deleteindex(ai, A, sA);
+ }
+ for (int i = 0; i < sb; i++) {
+ insert(b, ai, A, sA);
+ }
+ for (int i = 0; i < sb; i++) {
+ deleteindex(bi, B, sB);
+ }
+ for (int i = 0; i < sa; i++) {
+ insert(a, bi, B, sB);
+ }
+ printf("A: %d %d %d\n", a, sa, ai);
+ printf("B: %d %d %d\n", b, sb, bi);
+ printf("A = ");
+ printarr(A, *sA);
+ printf("B = ");
+ printarr(B, *sB);
+}
+
+void deletemax3(int arr[], int* len) {
+ int max = arr[0];
+ int maxi = 0;
+ for (int i = 1; i < *len; i++) {
+ if (arr[i] > max && arr[i] % 3 == 0) {
+ max = arr[i];
+ maxi = i;
+ }
+ }
+ deleteindex(maxi, arr, len);
+}
+
+//#define ARRLEN 10
+
+int main() {
+ SetConsoleCP(1251);
+ SetConsoleOutputCP(1251);
+
+ int arr[20] = { 3, 7, 12, 3, 4, 8, -1, 6, 1, 7 };
+ int size = 10;
+ int A[20] = {3, 2, 2, 5, 2, 1, 1, 1, 3, 9};
+ int sA = 10;
+ int B[20] = {1, 2, 5, 5, 4, 8, 3, 3};
+ int sB = 8;
+ int id, val;
+
+ int n = 0;
+ do {
+ puts("\n");
+ printf(" : ");
+ printarr(arr, size);
+ puts(" ");
+ puts("1) ");
+ puts("2) ");
+ puts("3) ");
+ puts("4) 0");
+ puts("5) ");
+ puts("6) ");
+ puts("7) , ");
+ puts("99) ");
+ puts("10) , ");
+ puts("11) A B ");
+ puts("");
+ puts("0) exit program");
+
+ while (scanf_s(" %d", &n) != 1) {
+ scanf_s("%*[^\n]");
+ scanf_s("%*c");
+ }
+ puts("");
+
+ switch (n)
+ {
+ case 1:
+ printf("delete index = ");
+ scanf_s("%d", &id);
+ deleteindex(id, arr, &size);
+ break;
+ case 2:
+ printf("value = ");
+ scanf_s("%d", &val);
+ printf("index = ");
+ scanf_s("%d", &id);
+ insert(val, id, arr, &size);
+ break;
+ case 3:
+ deleteindex(index(arrmin(arr, size), arr, size), arr, &size);
+ break;
+ case 4:
+ insert(0, index(arrmin(arr, size), arr, size), arr, &size);
+ break;
+ case 5:
+ for (int i = 0; i < size; i++) {
+ if (arr[i] % 2 == 0) deleteindex(i, arr, &size);
+ }
+ break;
+ case 6:
+ for (int i = 0; i < size; i++) {
+ if (arr[i] % 2 == 0) {
+ insert(arr[i], i, arr, &size);
+ i += 2;
+ }
+ }
+ break;
+ case 7:
+ insert(arrmin(arr, size), 0, arr, &size);
+ break;
+ case 99:
+ deletemax3(arr, &size);
+ break;
+ case 10:
+ for (int i = 0; i < size; i++) {
+ if (count(arr[i], arr, size) == 1) {
+ deleteindex(index(arr[i], arr, size), arr, &size);
+ i -= 1;
+ }
+ }
+ break;
+ case 11:
+ exchange_max_chains(A, B, &sA, &sB);
+ break;
+ case 0:
+ puts("goodbye :3");
+ break;
+ default:
+ puts("error: wrong N");
+ break;
+ }
+
+ } while (n != 0);
+ return 0;
+}
diff --git a/lab5-6-7-8-11/lab5-6/lab5-6-7-8.cpp b/lab5-6-7-8-11/lab5-6/lab5-6-7-8.cpp
index 5acfac0..e817547 100644
--- a/lab5-6-7-8-11/lab5-6/lab5-6-7-8.cpp
+++ b/lab5-6-7-8-11/lab5-6/lab5-6-7-8.cpp
@@ -1,642 +1,642 @@
-// lab5-6.cpp : Определяет точку входа для приложения.
-//
-
-#include "framework.h"
-#include "lab5-6.h"
-#include "stdio.h"
-
-
-#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_LAB56, szWindowClass, MAX_LOADSTRING);
- MyRegisterClass(hInstance);
-
- // Выполнить инициализацию приложения:
- if (!InitInstance (hInstance, nCmdShow))
- {
- return FALSE;
- }
-
- HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LAB56));
-
- 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_LAB56));
- wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
- wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_LAB56);
- 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;
-}
-
-//Рисует квадратную сетку с шагом в 50 пикселей от нуля до указанных координат
-void drawNet(HDC hdc, int width, int height) {
- for (int i = 0; i <= width; i = i + 50) {
- MoveToEx(hdc, i, 0, NULL);
- LineTo(hdc, i, height);
- }
-
- for (int i = 0; i <= height; i = i + 50) {
- MoveToEx(hdc, 0, i, NULL);
- LineTo(hdc, width, i);
- }
-}
-
-void drawTractor(HDC hdc, int cx, int cy) {
- HBRUSH hBrush;
- HPEN hPen;
- hBrush = CreateSolidBrush(RGB(0, 0, 150));
- SelectObject(hdc, hBrush);
- hPen = CreatePen(PS_SOLID, 5, RGB(0, 0, 100));
- SelectObject(hdc, hPen);
- Rectangle(hdc, cx-150, cy-50, cx+150, cy+50);
- MoveToEx(hdc, cx + 150, cy - 50, NULL);
- LineTo(hdc, cx + 150, cy - 150);
- LineTo(hdc, cx + 50, cy - 150);
- hPen = CreatePen(PS_SOLID, 5, RGB(153, 217, 234));
- SelectObject(hdc, hPen);
- LineTo(hdc, cx, cy - 50);
- hPen = CreatePen(PS_SOLID, 5, RGB(0, 0, 0));
- SelectObject(hdc, hPen);
- hBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(20, 20, 20));
- SelectObject(hdc, hBrush);
- Ellipse(hdc, cx-175, cy+25, cx-75, cy+125);
- Ellipse(hdc, cx + 25, cy - 25, cx + 175, cy + 125);
- DeleteObject(hPen);
- DeleteObject(hBrush);
-}
-
-void drawHouse(HDC hdc){
- HPEN hPen;
- hPen = CreatePen(PS_SOLID, 5, RGB(255, 0, 0));
- SelectObject(hdc, hPen);
-
- //крыша и стены
- MoveToEx(hdc, 150, 250, NULL);
- LineTo(hdc, 300, 50);
- LineTo(hdc, 450, 250);
- LineTo(hdc, 150, 250);
- LineTo(hdc, 150, 500);
- LineTo(hdc, 450, 500);
- LineTo(hdc, 450, 250);
- //окно
- MoveToEx(hdc, 200, 300, NULL);
- LineTo(hdc, 200, 400);
- LineTo(hdc, 300, 400);
- LineTo(hdc, 300, 300);
- LineTo(hdc, 200, 300);
- MoveToEx(hdc, 250, 300, NULL);
- LineTo(hdc, 250, 400);
- DeleteObject(hPen);
-}
-
-void drawSpruce(HDC hdc) {
- HPEN hPen;
- hPen = CreatePen(PS_SOLID, 5, RGB(30, 200, 80));
- SelectObject(hdc, hPen);
- //ёлка
- MoveToEx(hdc, 0, 600, NULL);
- LineTo(hdc, 150, 600);
- LineTo(hdc, 75, 500);
- LineTo(hdc, 0, 600);
- MoveToEx(hdc, 25, 500, NULL);
- LineTo(hdc, 125, 500);
- LineTo(hdc, 75, 400);
- LineTo(hdc, 25, 500);
- MoveToEx(hdc, 50, 400, NULL);
- LineTo(hdc, 100, 400);
- LineTo(hdc, 75, 300);
- LineTo(hdc, 50, 400);
- DeleteObject(hPen);
-}
-
-void drawCar(HDC hdc) {
- HPEN hPen;
- HBRUSH hBrush;
- //корпус авто
- hBrush = CreateSolidBrush(RGB(100, 100, 100));
- SelectObject(hdc, hBrush);
- hPen = CreatePen(PS_SOLID, 5, RGB(50, 50, 50));
- SelectObject(hdc, hPen);
- Rectangle(hdc, 550, 350, 850, 450);
- //крыша авто
- hPen = CreatePen(PS_SOLID, 5, RGB(0, 162, 232));
- SelectObject(hdc, hPen);
- MoveToEx(hdc, 550, 350, NULL);
- LineTo(hdc, 650, 250);
- LineTo(hdc, 800, 250);
- LineTo(hdc, 850, 350);
- //колёса
- hPen = CreatePen(PS_SOLID, 5, RGB(0, 0, 0));
- SelectObject(hdc, hPen);
- hBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(20, 20, 20));
- SelectObject(hdc, hBrush);
- Ellipse(hdc, 560, 410, 640, 490);
- Ellipse(hdc, 560 + 200, 410, 640 + 200, 490);
- DeleteObject(hPen);
- DeleteObject(hBrush);
-}
-
-void drawTree(HDC hdc) {
- HPEN hPen;
- HBRUSH hBrush;
- //ствол дерева
- hPen = CreatePen(PS_SOLID, 25, RGB(114, 78, 54));
- SelectObject(hdc, hPen);
- MoveToEx(hdc, 950, 500, NULL);
- LineTo(hdc, 950, 200);
- //листва дерева
- hPen = CreatePen(PS_SOLID, 5, RGB(30, 150, 80));
- SelectObject(hdc, hPen);
- hBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(30, 210, 80));
- SelectObject(hdc, hBrush);
- Ellipse(hdc, 850, 50, 1050, 350);
- DeleteObject(hPen);
- DeleteObject(hBrush);
-}
-
-//Рисует логотип Шевроле
-void drawLogo(HDC hdc, int cx, int cy) {
- POINT pt[12];
- pt[0].x = cx + 50; pt[0].y = cy + 50;
- pt[1].x = cx - 50; pt[1].y = cy + 50;
- pt[2].x = cx - 50; pt[2].y = cy + 25;
- pt[3].x = cx - 150; pt[3].y = cy + 25;
- pt[4].x = cx - 125; pt[4].y = cy - 25;
- pt[5].x = cx - 50; pt[5].y = cy - 25;
- pt[6].x = cx - 50; pt[6].y = cy - 50;
- pt[7].x = cx + 50; pt[7].y = cy - 50;
- pt[8].x = cx + 50; pt[8].y = cy - 25;
- pt[9].x = cx + 150; pt[9].y = cy - 25;
- pt[10].x = cx + 125; pt[10].y = cy + 25;
- pt[11].x = cx + 50; pt[11].y = cy + 25;
-
- HPEN hPen;
- HBRUSH hBrush;
- hPen = CreatePen(PS_SOLID, 10, RGB(180, 180, 180));
- hBrush = CreateHatchBrush(HS_CROSS, RGB(255, 215, 104));
- SelectObject(hdc, hPen);
- SelectObject(hdc, hBrush);
-
- Polygon(hdc, pt, 12);
-
- DeleteObject(hPen);
- DeleteObject(hBrush);
-}
-
-void lab5(HDC hdc) {
- drawHouse(hdc);
- drawSpruce(hdc);
- drawCar(hdc);
- drawTree(hdc);
- drawTractor(hdc, 1200, 450);
-}
-
-void lab6(HDC hdc) {
- HPEN hPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
- SelectObject(hdc, hPen);
- int x1 = 100;
- do {
- MoveToEx(hdc, 400, 300, NULL);
- LineTo(hdc, x1, 100);
- x1 += 25;
- } while (x1 <= 700);
-
- int x2 = 600, y2 = 400;
- do {
- MoveToEx(hdc, 800, 400, NULL);
- LineTo(hdc, x2, y2);
- x2 += 10;
- y2 -= 16;
- } while (x2 < 800);
- do {
- MoveToEx(hdc, 800, 400, NULL);
- LineTo(hdc, x2, y2);
- x2 += 10;
- y2 += 16;
- } while (x2 <= 1000);
-
- int x3 = 1100;
- do {
- MoveToEx(hdc, x3, 50, NULL);
- LineTo(hdc, x3, 300);
- x3 += 5;
- } while (x3 <= 1400);
-
- int x4 = 100, y4 = 350;
- int x5 = 400, y5 = 350;
- int i = 0;
- do {
- MoveToEx(hdc, x4, y4, NULL);
- LineTo(hdc, x5, y5);
- y4 += 10;
- x5 -= 10;
- i++;
- } while (i <= 30);
-
- int x6 = 600, y6 = 600;
- int dy = 10;
- i = 0;
-
- do {
- MoveToEx(hdc, x6, y6 - dy, NULL);
- LineTo(hdc, x6, y6 + dy);
- x6 += 10;
- dy += 10;
- i++;
- } while (i < 15);
-}
-
-void lab8(HDC hdc) {
- /*drawLogo(hdc, 155, 55);
- drawLogo(hdc, 155+300, 55);
- drawLogo(hdc, 155, 55+300);
- drawLogo(hdc, 155+300, 55+300);
- drawLogo(hdc, 155 + 150, 55 + 150);*/
-
- int x1 = 0, y1 = 0;
- int i = 0;
- do {
- drawLogo(hdc, 155 + x1, 55 + y1);
- x1 += 125;
- y1 += 125;
- i++;
- } while (i < 5);
-}
-
-int imageNum = 1;
-bool netToggle = true;
-
-//Рисует картинки по нажатию цифры на клавиатуре
-void drawImageSequence1(HDC hdc) {
- switch (imageNum)
- {
- case 0:
- lab5(hdc);
- break;
- case 1:
- drawSpruce(hdc);
- break;
- case 2:
- drawHouse(hdc);
- break;
- case 3:
- drawLogo(hdc, 500, 300);
- break;
- case 4:
- drawCar(hdc);
- break;
- case 5:
- drawTree(hdc);
- break;
- case 6:
- drawTractor(hdc, 1200, 450);
- break;
- }
-}
-
-void draw5logos(HDC hdc, RECT rect) {
- drawLogo(hdc, rect.right - 200, rect.bottom - 100);
- drawLogo(hdc, rect.right - 200, rect.top + 100);
- drawLogo(hdc, rect.left + 200, rect.bottom - 100);
- drawLogo(hdc, rect.right / 2, rect.bottom / 2);
-}
-
-void drawImage1(HDC hdc, int cx, int cy, COLORREF color) {
- HPEN hPen = CreatePen(PS_SOLID, 4, color);
- SelectObject(hdc, hPen);
-
- POINT p[4] = {
- cx, cy - 20,
- cx + 20, cy + 20,
- cx - 20, cy + 20,
- cx, cy - 20
- };
- Polyline(hdc, p, 4);
-
- DeleteObject(hPen);
-}
-
-void drawImage2(HDC hdc, int cx, int cy, COLORREF color) {
- HPEN hPen = CreatePen(PS_SOLID, 4, color);
- SelectObject(hdc, hPen);
-
- POINT p[5] = {
- cx, cy - 20,
- cx + 20, cy,
- cx, cy + 20,
- cx - 20, cy,
- cx, cy - 20
- };
- Polyline(hdc, p, 5);
-
- DeleteObject(hPen);
-}
-
-void drawImage3(HDC hdc, int cx, int cy, COLORREF color) {
- HPEN hPen = CreatePen(PS_SOLID, 4, color);
- SelectObject(hdc, hPen);
-
- POINT p[5] = {
- cx, cy,
- cx + 20, cy - 20,
- cx, cy + 20,
- cx - 20, cy - 20,
- cx, cy
- };
- Polyline(hdc, p, 5);
-
- DeleteObject(hPen);
-}
-
-void drawImage4(HDC hdc, int cx, int cy, COLORREF color) {
- HPEN hPen = CreatePen(PS_SOLID, 4, color);
- SelectObject(hdc, hPen);
-
- POINT p[6] = {
- cx - 20, cy + 20,
- cx - 20, cy - 20,
- cx + 20, cy - 20,
- cx, cy - 10,
- cx + 20, cy,
- cx - 20, cy
- };
- Polyline(hdc, p, 6);
-
- DeleteObject(hPen);
-}
-
-void drawImage5(HDC hdc, int cx, int cy, COLORREF color) {
- HPEN hPen = CreatePen(PS_SOLID, 4, color);
- SelectObject(hdc, hPen);
-
- POINT p[6] = {
- cx, cy ,
- cx + 20, cy - 20,
- cx + 20, cy + 20,
- cx - 20, cy + 20,
- cx - 20, cy - 20,
- cx, cy
- };
- Polyline(hdc, p, 6);
-
- DeleteObject(hPen);
-}
-
-void drawImageNet(HDC hdc, int cx, int cy, int width, int height, int step, void (*image)(HDC hdc, int cx, int cy, COLORREF color)) {
- int r, g, b, fb;
- r = 255;
- g = 40;
- b = 0;
- int dr, dg, db;
- dr = r / width;
- dg = (255 - g) / width;
- db = (255 - b) / height;
- for (int i = cx; i <= width * step; i += step) {
- fb = b;
- for (int j = cy; j <= height * step; j += step) {
- image(hdc, i, j, RGB(r, g, fb));
- fb += db;
- }
- //r -= dr;
- g += dg;
- }
-}
-
-enum Modes {
- image1,
- image2,
- image3,
- image4,
- image5
-} mode;
-
-void drawImageSequence2(HDC hdc, int cx, int cy, int width, int height, int step) {
- switch (mode)
- {
- case image1:
- drawImageNet(hdc, cx, cy, width, height, step, drawImage1);
- break;
- case image2:
- drawImageNet(hdc, cx, cy, width, height, step, drawImage2);
- break;
- case image3:
- drawImageNet(hdc, cx, cy, width, height, step, drawImage3);
- break;
- case image4:
- drawImageNet(hdc, cx, cy, width, height, step, drawImage4);
- break;
- case image5:
- drawImageNet(hdc, cx, cy, width, height, step, drawImage5);
- break;
- }
-}
-
-//
-// ФУНКЦИЯ: 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...
-
- RECT rect;
- GetClientRect(hWnd, &rect);
-
- if (netToggle) drawNet(hdc, rect.right, rect.bottom); //drawNet(hdc, 1400, 650);
-
- drawImageSequence1(hdc);
-
- //lab5(hdc);
-
- //lab6(hdc);
-
- //lab8(hdc);
-
- //draw5logos(hdc, rect);
-
- //drawImageNet(hdc, 50, 50, 8, 8, 100, drawImage4);
-
- //drawImageSequence2(hdc, 50, 50, 12, 8, 100);
-
- EndPaint(hWnd, &ps);
- }
- break;
- case WM_KEYDOWN:
- {
- switch (wParam)
- {
- case VK_SPACE:
- netToggle = !netToggle;
- break;
- case 0x30:
- imageNum = 0;
- break;
- case 0x31:
- imageNum = 1;
- mode = image1;
- break;
- case 0x32:
- imageNum = 2;
- mode = image2;
- break;
- case 0x33:
- imageNum = 3;
- mode = image3;
- break;
- case 0x34:
- imageNum = 4;
- mode = image4;
- break;
- case 0x35:
- imageNum = 5;
- mode = image5;
- break;
- case 0x36:
- imageNum = 6;
- break;
- }
- 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;
-}
+// lab5-6.cpp : Определяет точку входа для приложения.
+//
+
+#include "framework.h"
+#include "lab5-6.h"
+#include "stdio.h"
+
+
+#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_LAB56, szWindowClass, MAX_LOADSTRING);
+ MyRegisterClass(hInstance);
+
+ // Выполнить инициализацию приложения:
+ if (!InitInstance (hInstance, nCmdShow))
+ {
+ return FALSE;
+ }
+
+ HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LAB56));
+
+ 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_LAB56));
+ wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
+ wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_LAB56);
+ 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;
+}
+
+//Рисует квадратную сетку с шагом в 50 пикселей от нуля до указанных координат
+void drawNet(HDC hdc, int width, int height) {
+ for (int i = 0; i <= width; i = i + 50) {
+ MoveToEx(hdc, i, 0, NULL);
+ LineTo(hdc, i, height);
+ }
+
+ for (int i = 0; i <= height; i = i + 50) {
+ MoveToEx(hdc, 0, i, NULL);
+ LineTo(hdc, width, i);
+ }
+}
+
+void drawTractor(HDC hdc, int cx, int cy) {
+ HBRUSH hBrush;
+ HPEN hPen;
+ hBrush = CreateSolidBrush(RGB(0, 0, 150));
+ SelectObject(hdc, hBrush);
+ hPen = CreatePen(PS_SOLID, 5, RGB(0, 0, 100));
+ SelectObject(hdc, hPen);
+ Rectangle(hdc, cx-150, cy-50, cx+150, cy+50);
+ MoveToEx(hdc, cx + 150, cy - 50, NULL);
+ LineTo(hdc, cx + 150, cy - 150);
+ LineTo(hdc, cx + 50, cy - 150);
+ hPen = CreatePen(PS_SOLID, 5, RGB(153, 217, 234));
+ SelectObject(hdc, hPen);
+ LineTo(hdc, cx, cy - 50);
+ hPen = CreatePen(PS_SOLID, 5, RGB(0, 0, 0));
+ SelectObject(hdc, hPen);
+ hBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(20, 20, 20));
+ SelectObject(hdc, hBrush);
+ Ellipse(hdc, cx-175, cy+25, cx-75, cy+125);
+ Ellipse(hdc, cx + 25, cy - 25, cx + 175, cy + 125);
+ DeleteObject(hPen);
+ DeleteObject(hBrush);
+}
+
+void drawHouse(HDC hdc){
+ HPEN hPen;
+ hPen = CreatePen(PS_SOLID, 5, RGB(255, 0, 0));
+ SelectObject(hdc, hPen);
+
+ //крыша и стены
+ MoveToEx(hdc, 150, 250, NULL);
+ LineTo(hdc, 300, 50);
+ LineTo(hdc, 450, 250);
+ LineTo(hdc, 150, 250);
+ LineTo(hdc, 150, 500);
+ LineTo(hdc, 450, 500);
+ LineTo(hdc, 450, 250);
+ //окно
+ MoveToEx(hdc, 200, 300, NULL);
+ LineTo(hdc, 200, 400);
+ LineTo(hdc, 300, 400);
+ LineTo(hdc, 300, 300);
+ LineTo(hdc, 200, 300);
+ MoveToEx(hdc, 250, 300, NULL);
+ LineTo(hdc, 250, 400);
+ DeleteObject(hPen);
+}
+
+void drawSpruce(HDC hdc) {
+ HPEN hPen;
+ hPen = CreatePen(PS_SOLID, 5, RGB(30, 200, 80));
+ SelectObject(hdc, hPen);
+ //ёлка
+ MoveToEx(hdc, 0, 600, NULL);
+ LineTo(hdc, 150, 600);
+ LineTo(hdc, 75, 500);
+ LineTo(hdc, 0, 600);
+ MoveToEx(hdc, 25, 500, NULL);
+ LineTo(hdc, 125, 500);
+ LineTo(hdc, 75, 400);
+ LineTo(hdc, 25, 500);
+ MoveToEx(hdc, 50, 400, NULL);
+ LineTo(hdc, 100, 400);
+ LineTo(hdc, 75, 300);
+ LineTo(hdc, 50, 400);
+ DeleteObject(hPen);
+}
+
+void drawCar(HDC hdc) {
+ HPEN hPen;
+ HBRUSH hBrush;
+ //корпус авто
+ hBrush = CreateSolidBrush(RGB(100, 100, 100));
+ SelectObject(hdc, hBrush);
+ hPen = CreatePen(PS_SOLID, 5, RGB(50, 50, 50));
+ SelectObject(hdc, hPen);
+ Rectangle(hdc, 550, 350, 850, 450);
+ //крыша авто
+ hPen = CreatePen(PS_SOLID, 5, RGB(0, 162, 232));
+ SelectObject(hdc, hPen);
+ MoveToEx(hdc, 550, 350, NULL);
+ LineTo(hdc, 650, 250);
+ LineTo(hdc, 800, 250);
+ LineTo(hdc, 850, 350);
+ //колёса
+ hPen = CreatePen(PS_SOLID, 5, RGB(0, 0, 0));
+ SelectObject(hdc, hPen);
+ hBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(20, 20, 20));
+ SelectObject(hdc, hBrush);
+ Ellipse(hdc, 560, 410, 640, 490);
+ Ellipse(hdc, 560 + 200, 410, 640 + 200, 490);
+ DeleteObject(hPen);
+ DeleteObject(hBrush);
+}
+
+void drawTree(HDC hdc) {
+ HPEN hPen;
+ HBRUSH hBrush;
+ //ствол дерева
+ hPen = CreatePen(PS_SOLID, 25, RGB(114, 78, 54));
+ SelectObject(hdc, hPen);
+ MoveToEx(hdc, 950, 500, NULL);
+ LineTo(hdc, 950, 200);
+ //листва дерева
+ hPen = CreatePen(PS_SOLID, 5, RGB(30, 150, 80));
+ SelectObject(hdc, hPen);
+ hBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(30, 210, 80));
+ SelectObject(hdc, hBrush);
+ Ellipse(hdc, 850, 50, 1050, 350);
+ DeleteObject(hPen);
+ DeleteObject(hBrush);
+}
+
+//Рисует логотип Шевроле
+void drawLogo(HDC hdc, int cx, int cy) {
+ POINT pt[12];
+ pt[0].x = cx + 50; pt[0].y = cy + 50;
+ pt[1].x = cx - 50; pt[1].y = cy + 50;
+ pt[2].x = cx - 50; pt[2].y = cy + 25;
+ pt[3].x = cx - 150; pt[3].y = cy + 25;
+ pt[4].x = cx - 125; pt[4].y = cy - 25;
+ pt[5].x = cx - 50; pt[5].y = cy - 25;
+ pt[6].x = cx - 50; pt[6].y = cy - 50;
+ pt[7].x = cx + 50; pt[7].y = cy - 50;
+ pt[8].x = cx + 50; pt[8].y = cy - 25;
+ pt[9].x = cx + 150; pt[9].y = cy - 25;
+ pt[10].x = cx + 125; pt[10].y = cy + 25;
+ pt[11].x = cx + 50; pt[11].y = cy + 25;
+
+ HPEN hPen;
+ HBRUSH hBrush;
+ hPen = CreatePen(PS_SOLID, 10, RGB(180, 180, 180));
+ hBrush = CreateHatchBrush(HS_CROSS, RGB(255, 215, 104));
+ SelectObject(hdc, hPen);
+ SelectObject(hdc, hBrush);
+
+ Polygon(hdc, pt, 12);
+
+ DeleteObject(hPen);
+ DeleteObject(hBrush);
+}
+
+void lab5(HDC hdc) {
+ drawHouse(hdc);
+ drawSpruce(hdc);
+ drawCar(hdc);
+ drawTree(hdc);
+ drawTractor(hdc, 1200, 450);
+}
+
+void lab6(HDC hdc) {
+ HPEN hPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
+ SelectObject(hdc, hPen);
+ int x1 = 100;
+ do {
+ MoveToEx(hdc, 400, 300, NULL);
+ LineTo(hdc, x1, 100);
+ x1 += 25;
+ } while (x1 <= 700);
+
+ int x2 = 600, y2 = 400;
+ do {
+ MoveToEx(hdc, 800, 400, NULL);
+ LineTo(hdc, x2, y2);
+ x2 += 10;
+ y2 -= 16;
+ } while (x2 < 800);
+ do {
+ MoveToEx(hdc, 800, 400, NULL);
+ LineTo(hdc, x2, y2);
+ x2 += 10;
+ y2 += 16;
+ } while (x2 <= 1000);
+
+ int x3 = 1100;
+ do {
+ MoveToEx(hdc, x3, 50, NULL);
+ LineTo(hdc, x3, 300);
+ x3 += 5;
+ } while (x3 <= 1400);
+
+ int x4 = 100, y4 = 350;
+ int x5 = 400, y5 = 350;
+ int i = 0;
+ do {
+ MoveToEx(hdc, x4, y4, NULL);
+ LineTo(hdc, x5, y5);
+ y4 += 10;
+ x5 -= 10;
+ i++;
+ } while (i <= 30);
+
+ int x6 = 600, y6 = 600;
+ int dy = 10;
+ i = 0;
+
+ do {
+ MoveToEx(hdc, x6, y6 - dy, NULL);
+ LineTo(hdc, x6, y6 + dy);
+ x6 += 10;
+ dy += 10;
+ i++;
+ } while (i < 15);
+}
+
+void lab8(HDC hdc) {
+ /*drawLogo(hdc, 155, 55);
+ drawLogo(hdc, 155+300, 55);
+ drawLogo(hdc, 155, 55+300);
+ drawLogo(hdc, 155+300, 55+300);
+ drawLogo(hdc, 155 + 150, 55 + 150);*/
+
+ int x1 = 0, y1 = 0;
+ int i = 0;
+ do {
+ drawLogo(hdc, 155 + x1, 55 + y1);
+ x1 += 125;
+ y1 += 125;
+ i++;
+ } while (i < 5);
+}
+
+int imageNum = 1;
+bool netToggle = true;
+
+//Рисует картинки по нажатию цифры на клавиатуре
+void drawImageSequence1(HDC hdc) {
+ switch (imageNum)
+ {
+ case 0:
+ lab5(hdc);
+ break;
+ case 1:
+ drawSpruce(hdc);
+ break;
+ case 2:
+ drawHouse(hdc);
+ break;
+ case 3:
+ drawLogo(hdc, 500, 300);
+ break;
+ case 4:
+ drawCar(hdc);
+ break;
+ case 5:
+ drawTree(hdc);
+ break;
+ case 6:
+ drawTractor(hdc, 1200, 450);
+ break;
+ }
+}
+
+void draw5logos(HDC hdc, RECT rect) {
+ drawLogo(hdc, rect.right - 200, rect.bottom - 100);
+ drawLogo(hdc, rect.right - 200, rect.top + 100);
+ drawLogo(hdc, rect.left + 200, rect.bottom - 100);
+ drawLogo(hdc, rect.right / 2, rect.bottom / 2);
+}
+
+void drawImage1(HDC hdc, int cx, int cy, COLORREF color) {
+ HPEN hPen = CreatePen(PS_SOLID, 4, color);
+ SelectObject(hdc, hPen);
+
+ POINT p[4] = {
+ cx, cy - 20,
+ cx + 20, cy + 20,
+ cx - 20, cy + 20,
+ cx, cy - 20
+ };
+ Polyline(hdc, p, 4);
+
+ DeleteObject(hPen);
+}
+
+void drawImage2(HDC hdc, int cx, int cy, COLORREF color) {
+ HPEN hPen = CreatePen(PS_SOLID, 4, color);
+ SelectObject(hdc, hPen);
+
+ POINT p[5] = {
+ cx, cy - 20,
+ cx + 20, cy,
+ cx, cy + 20,
+ cx - 20, cy,
+ cx, cy - 20
+ };
+ Polyline(hdc, p, 5);
+
+ DeleteObject(hPen);
+}
+
+void drawImage3(HDC hdc, int cx, int cy, COLORREF color) {
+ HPEN hPen = CreatePen(PS_SOLID, 4, color);
+ SelectObject(hdc, hPen);
+
+ POINT p[5] = {
+ cx, cy,
+ cx + 20, cy - 20,
+ cx, cy + 20,
+ cx - 20, cy - 20,
+ cx, cy
+ };
+ Polyline(hdc, p, 5);
+
+ DeleteObject(hPen);
+}
+
+void drawImage4(HDC hdc, int cx, int cy, COLORREF color) {
+ HPEN hPen = CreatePen(PS_SOLID, 4, color);
+ SelectObject(hdc, hPen);
+
+ POINT p[6] = {
+ cx - 20, cy + 20,
+ cx - 20, cy - 20,
+ cx + 20, cy - 20,
+ cx, cy - 10,
+ cx + 20, cy,
+ cx - 20, cy
+ };
+ Polyline(hdc, p, 6);
+
+ DeleteObject(hPen);
+}
+
+void drawImage5(HDC hdc, int cx, int cy, COLORREF color) {
+ HPEN hPen = CreatePen(PS_SOLID, 4, color);
+ SelectObject(hdc, hPen);
+
+ POINT p[6] = {
+ cx, cy ,
+ cx + 20, cy - 20,
+ cx + 20, cy + 20,
+ cx - 20, cy + 20,
+ cx - 20, cy - 20,
+ cx, cy
+ };
+ Polyline(hdc, p, 6);
+
+ DeleteObject(hPen);
+}
+
+void drawImageNet(HDC hdc, int cx, int cy, int width, int height, int step, void (*image)(HDC hdc, int cx, int cy, COLORREF color)) {
+ int r, g, b, fb;
+ r = 255;
+ g = 40;
+ b = 0;
+ int dr, dg, db;
+ dr = r / width;
+ dg = (255 - g) / width;
+ db = (255 - b) / height;
+ for (int i = cx; i <= width * step; i += step) {
+ fb = b;
+ for (int j = cy; j <= height * step; j += step) {
+ image(hdc, i, j, RGB(r, g, fb));
+ fb += db;
+ }
+ //r -= dr;
+ g += dg;
+ }
+}
+
+enum Modes {
+ image1,
+ image2,
+ image3,
+ image4,
+ image5
+} mode;
+
+void drawImageSequence2(HDC hdc, int cx, int cy, int width, int height, int step) {
+ switch (mode)
+ {
+ case image1:
+ drawImageNet(hdc, cx, cy, width, height, step, drawImage1);
+ break;
+ case image2:
+ drawImageNet(hdc, cx, cy, width, height, step, drawImage2);
+ break;
+ case image3:
+ drawImageNet(hdc, cx, cy, width, height, step, drawImage3);
+ break;
+ case image4:
+ drawImageNet(hdc, cx, cy, width, height, step, drawImage4);
+ break;
+ case image5:
+ drawImageNet(hdc, cx, cy, width, height, step, drawImage5);
+ break;
+ }
+}
+
+//
+// ФУНКЦИЯ: 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...
+
+ RECT rect;
+ GetClientRect(hWnd, &rect);
+
+ if (netToggle) drawNet(hdc, rect.right, rect.bottom); //drawNet(hdc, 1400, 650);
+
+ //drawImageSequence1(hdc);
+
+ //lab5(hdc);
+
+ //lab6(hdc);
+
+ //lab8(hdc);
+
+ //draw5logos(hdc, rect);
+
+ //drawImageNet(hdc, 50, 50, 8, 8, 100, drawImage4);
+
+ drawImageSequence2(hdc, 50, 50, 12, 8, 100);
+
+ EndPaint(hWnd, &ps);
+ }
+ break;
+ case WM_KEYDOWN:
+ {
+ switch (wParam)
+ {
+ case VK_SPACE:
+ netToggle = !netToggle;
+ break;
+ case 0x30:
+ imageNum = 0;
+ break;
+ case 0x31:
+ imageNum = 1;
+ mode = image1;
+ break;
+ case 0x32:
+ imageNum = 2;
+ mode = image2;
+ break;
+ case 0x33:
+ imageNum = 3;
+ mode = image3;
+ break;
+ case 0x34:
+ imageNum = 4;
+ mode = image4;
+ break;
+ case 0x35:
+ imageNum = 5;
+ mode = image5;
+ break;
+ case 0x36:
+ imageNum = 6;
+ break;
+ }
+ 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;
+}