Advertisement
Guest User

lab11

a guest
Nov 21st, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <winbgim.h>
  3. using namespace std;
  4. const int WID = 800, HIGH = 600, scale = 50;
  5. const double step = 0.01;
  6.  
  7. void drawLine(int moveToX, int moveToY, int drawX, int drawY, int color, int textX, int textY, char *name) {
  8.     moveto(moveToX, moveToY);
  9.     setcolor(color);
  10.     lineto(drawX, drawY);
  11.     outtextxy(textX, textY, name);
  12. }
  13.  
  14. int main() {    
  15.     double y1, y2;
  16.     initwindow(WID, HIGH);
  17.     moveto(WID / 2, HIGH / 2);
  18.     vector<double> ab;
  19.     bool xo;
  20.    
  21.     moveto(WID / 2 + (WID*WID * scale), HIGH / 2 - (WID*WID * scale));
  22.     for (double x1 = -WID; x1 < WID; x1 += step) {
  23.         y1 = 2;
  24.         setcolor(15); // Oaao ooieoee
  25.         lineto((WID / 2) + (x1 * scale), (HIGH / 2) - (y1 * scale));
  26.     }
  27.     moveto(WID / 2, HIGH / 2);
  28.     moveto(WID / 2 + (-WID * scale), HIGH / 2 - (25-(-WID*-WID)) * scale);
  29.     for (double x2 = -WID; x2 < WID; x2 += step) {
  30.         y1 = 2;
  31.         y2 = sqrt(25-x2*x2);
  32.         setcolor(15); // Oaao ooieoee
  33.         lineto(WID / 2 + (x2 * scale), HIGH / 2 - (y2 * scale));
  34.         if(y1-step<y2&&y2<y1+step) ab.push_back(x2);
  35.     }
  36.     moveto(WID / 2, HIGH / 2);
  37.    
  38.     setcolor(15);
  39.     outtextxy(460,30,"y=sqrt(25-x*x)");
  40.     outtextxy(680,150,"y=2");
  41.     cout << "a = " << ab[0] << endl;
  42.     cout << "b = " << ab[1] << endl;
  43.     outtextxy(WID/2 + (ab[0]*scale), HIGH/2,"a");
  44.     outtextxy(WID/2 + (ab[1]*scale), HIGH/2,"b");
  45.    
  46.     drawLine(0, HIGH / 2 - 2, WID, HIGH / 2 - 2, 15, WID - 20, HIGH / 2 + 10, "X");
  47.     drawLine(WID / 2, 0, WID / 2, HIGH, 15, WID / 2 + 10, 0, "Y");
  48.    
  49.     setfillstyle(1,COLOR(60, 179, 113));
  50.    floodfill(WID / 2 + (-1 * scale), HIGH / 2 - (1 * scale), 15);
  51.    floodfill(WID / 2 + (1 * scale), HIGH / 2 - (1 * scale), 15);
  52.  
  53.     getch();
  54.     closegraph();
  55.     system("PAUSE");
  56.     return 0;
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement