vadimk772336

Untitled

Dec 18th, 2019
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. double f(double x)
  8. {
  9.     return x*x+1000;
  10. }
  11. /*double privedenie_po_Y(double y) {
  12.     double result = 100 * y + (double)(597/ 4);
  13.     return result;
  14. }*/
  15. int main()
  16. {
  17.     float x;
  18.     HDC hDC = GetDC(GetConsoleWindow());
  19.     HWND hwnd = GetConsoleWindow();
  20.     RECT Rect;
  21.     GetWindowRect(hwnd, &Rect);
  22.     double size_x = Rect.right - Rect.left - 40;
  23.     double size_y = Rect.bottom - Rect.top - 50;
  24.     cout << size_y;
  25.     HPEN Pen = CreatePen(PS_SOLID, 4, RGB(255, 255, 255));
  26.     SelectObject(hDC, Pen);
  27.     double a = f(0);
  28.     while (true)
  29.     {
  30.         GetWindowRect(hwnd, &Rect);
  31.         double size_x = Rect.right - Rect.left - 40;
  32.         double size_y = Rect.bottom - Rect.top - 50;
  33.         MoveToEx(hDC, 0,  size_y / 2 + (a), NULL);
  34.         LineTo(hDC, 1 * size_x, 1 * size_y / 2+(a));
  35.         MoveToEx(hDC, 1 * size_x / 2, 0, NULL);
  36.         LineTo(hDC, 1 * size_x / 2, 1 * size_y);
  37.         for (x = -3.14; x <= 3.14; x += 0.01)
  38.         {
  39.             MoveToEx(hDC, 100 * x + 1 * size_x / 2, -100 * (f(x)- a) + 1 * size_y / 2, NULL);
  40.             LineTo(hDC, 100 * x + 1 * size_x / 2, -100 * (f(x)- a) + 1 * size_y / 2);
  41.         }
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment