Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <graphics.h>
  4. using namespace std;
  5. int main()
  6. {
  7.     const float startX = - 3, finishX = 5;
  8.     float x, y, x1, y1, p;
  9.  
  10.     cout << "vvedite shag: ";
  11.     cin >> p;
  12.  
  13.     initwindow(800, 400 ) ;
  14.     setfillstyle( 1, 15 );
  15.     line( 0, 200, 800, 200 );
  16.     line( 250, 0, 250, 400 );
  17.     line( 250, 0, 240, 10 );
  18.     line( 250, 0, 260, 10 );
  19.     line( 800, 200, 790, 210 );
  20.     line( 800, 200, 790, 190 );
  21.  
  22.  
  23.     outtextxy( 790, 210, "X");
  24.     outtextxy(240, 10, "Y");
  25.  
  26.  
  27.     moveto(50,250);
  28.     for(float x=startX; x <= finishX; x+=p)
  29.     {
  30.       if ((x >= -3) and (x <= -2))
  31.       {
  32.         y = - x - 2;
  33.         x1 = 250 + x*50;
  34.         y1 = 200 - y*50;
  35.         setcolor(10);
  36.         circle(x1,y1,3);
  37.         setfillstyle(1,10);
  38.         floodfill(x1,y1,10);
  39.         lineto(x1,y1);
  40.         }
  41.         if ( (x >= -2) && (x <= -1))
  42.         {
  43.           y = sqrt(1 - (x + 1) * (x + 1));
  44.           x1 = 250 + x*50;
  45.           y1 = 200 - y*50;
  46.           setcolor(10);
  47.           circle( x1,y1,3 );
  48.           setfillstyle( 1,10 );
  49.           floodfill(x1,y1,10 );
  50.           arc ( 200 , 200 , 90 , 180 , 50 ) ;
  51.           }
  52.         if ((x >= -1) && (x <= 1))
  53.         {
  54.           y = 1;
  55.           x1 = 250 + x*50;
  56.           y1 = 200 - y*50;
  57.           setcolor(10);
  58.           circle( x1,y1,3 );
  59.           setfillstyle( 1, 10 );
  60.           floodfill(x1,y1,10 );
  61.           lineto( x1,y1 );
  62.           }
  63.           if ((x >= 1) && (x <= 2))
  64.             {
  65.               y = -2*x + 3;
  66.               x1 = 250 + x*50;
  67.               y1 = 200 - y* 50;
  68.               setcolor(10);
  69.               circle( x1,y1,3 );
  70.               setfillstyle( 1, 10 );
  71.               floodfill(x1,y1,10 );
  72.                lineto( x1,y1 );
  73.               }
  74.               if ((x >= 2) && (x <= 5))
  75.             {
  76.               y = - x / x;
  77.               x1 = 250 + x*50;
  78.               y1 = 200 - y* 50;
  79.               setcolor(10);
  80.               circle( x1,y1,3 );
  81.               setfillstyle( 1, 10 );
  82.               floodfill(x1,y1,10 );
  83.               lineto( x1,y1 );
  84.               }
  85.               }
  86.  
  87.  
  88. getch();
  89. closegraph();
  90. return 0;
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement