Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Прога выводит график, зарисовывает минимальный, максимальный элемент и зарисовывает цветом чётные элементы, расположенные между min max
- #include "framework.h"
- #include "lab6.h"
- #define MAX_LOADSTRING 100
- int a[5] = { 100,31,70,-57,62 };
- void zxc(HDC hdc, int x, int y, int p)
- {
- HBRUSH hpen0 = CreateSolidBrush(RGB(255, 0, 0));
- HBRUSH hbrush0 = CreateSolidBrush(RGB(255, 255, 255));
- HBRUSH MinBrush = CreateSolidBrush(RGB(123, 123, 245));
- HBRUSH MaxBrush = CreateSolidBrush(RGB(210, 123, 234));
- int max = 0;
- int min = 100;
- int imax = 0;
- int imin = 0;
- for (int i = 0; i < 5; i++)
- {
- if (a[i] < min) {
- min = a[i];
- imin = i;
- }
- if (a[i] > max) {
- max = a[i];
- imax = i;
- }
- }
- if (imin > imax)
- {
- int temp = imin;
- imin = imax;
- imax = temp;
- }
- int cx = 0;
- int ry = 150;
- int rx = 300;
- for (int i = 0; i < p; i++)
- {
- SelectObject(hdc, hbrush0);
- if ((i < imax) && (i > imin) && (a[i] % 2 == 0))
- {
- SelectObject(hdc, hpen0);
- }
- if (i == imax)
- {
- SelectObject(hdc, MaxBrush);
- }
- if (i == imin)
- {
- SelectObject(hdc, MinBrush);
- }
- Rectangle(hdc, x + cx, y - a[i], x + cx + 40, y);
- cx += 40;
- }
- MoveToEx(hdc, x, y, NULL);
- LineTo(hdc, x, y - ry);
- LineTo(hdc, x, y - ry);
- LineTo(hdc, x + 10, y - ry + 20);
- MoveToEx(hdc, x, y - ry, NULL);
- LineTo(hdc, x - 10, y - ry + 20);
- MoveToEx(hdc, x, y, NULL);
- LineTo(hdc, x, y + ry);
- LineTo(hdc, x, y + ry);
- LineTo(hdc, x + 10, y + ry - 20);
- MoveToEx(hdc, x, y + ry, NULL);
- LineTo(hdc, x - 10, y + ry - 20);
- MoveToEx(hdc, x, y, NULL);
- LineTo(hdc, x + rx, y);
- LineTo(hdc, x + rx - 10, y + 20);
- MoveToEx(hdc, x + rx, y, NULL);
- LineTo(hdc, x + rx - 10, y - 20);
- }
- void zxcmain(HDC hdc, int x, int y, int p)
- {
- int max = 0;
- int min = 100;
- int imax = 0;
- int imin = 0;
- for (int i = 0; i < 5; i++)
- {
- if (a[i] < min) {
- min = a[i];
- imin = i;
- }
- if (a[i] > max) {
- max = a[i];
- imax = i;
- }
- }
- int cx = 0;
- int ry = 150;
- int rx = 300;
- for (int i = 0; i < p; i++)
- {
- Rectangle(hdc, x + cx, y - a[i], x + cx + 40, y);
- cx += 40;
- }
- MoveToEx(hdc, x, y, NULL);
- LineTo(hdc, x, y - ry);
- LineTo(hdc, x, y - ry);
- LineTo(hdc, x + 10, y - ry + 20);
- MoveToEx(hdc, x, y - ry, NULL);
- LineTo(hdc, x - 10, y - ry + 20);
- MoveToEx(hdc, x, y, NULL);
- LineTo(hdc, x, y + ry);
- LineTo(hdc, x, y + ry);
- LineTo(hdc, x + 10, y + ry - 20);
- MoveToEx(hdc, x, y + ry, NULL);
- LineTo(hdc, x - 10, y + ry - 20);
- MoveToEx(hdc, x, y, NULL);
- LineTo(hdc, x + rx, y);
- LineTo(hdc, x + rx - 10, y + 20);
- MoveToEx(hdc, x + rx, y, NULL);
- LineTo(hdc, x + rx - 10, y - 20);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement