Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <graphics.h>
- using namespace std;
- int main()
- {
- const float startX = - 3, finishX = 5;
- float x, y, x1, y1, p;
- cout << "vvedite shag: ";
- cin >> p;
- initwindow(800, 400 ) ;
- setfillstyle( 1, 15 );
- line( 0, 200, 800, 200 );
- line( 250, 0, 250, 400 );
- line( 250, 0, 240, 10 );
- line( 250, 0, 260, 10 );
- line( 800, 200, 790, 210 );
- line( 800, 200, 790, 190 );
- outtextxy( 790, 210, "X");
- outtextxy(240, 10, "Y");
- moveto(50,250);
- for(float x=startX; x <= finishX; x+=p)
- {
- if ((x >= -3) and (x <= -2))
- {
- y = - x - 2;
- x1 = 250 + x*50;
- y1 = 200 - y*50;
- setcolor(10);
- circle(x1,y1,3);
- setfillstyle(1,10);
- floodfill(x1,y1,10);
- lineto(x1,y1);
- }
- if ( (x >= -2) && (x <= -1))
- {
- y = sqrt(1 - (x + 1) * (x + 1));
- x1 = 250 + x*50;
- y1 = 200 - y*50;
- setcolor(10);
- circle( x1,y1,3 );
- setfillstyle( 1,10 );
- floodfill(x1,y1,10 );
- arc ( 200 , 200 , 90 , 180 , 50 ) ;
- }
- if ((x >= -1) && (x <= 1))
- {
- y = 1;
- x1 = 250 + x*50;
- y1 = 200 - y*50;
- setcolor(10);
- circle( x1,y1,3 );
- setfillstyle( 1, 10 );
- floodfill(x1,y1,10 );
- lineto( x1,y1 );
- }
- if ((x >= 1) && (x <= 2))
- {
- y = -2*x + 3;
- x1 = 250 + x*50;
- y1 = 200 - y* 50;
- setcolor(10);
- circle( x1,y1,3 );
- setfillstyle( 1, 10 );
- floodfill(x1,y1,10 );
- lineto( x1,y1 );
- }
- if ((x >= 2) && (x <= 5))
- {
- y = - x / x;
- x1 = 250 + x*50;
- y1 = 200 - y* 50;
- setcolor(10);
- circle( x1,y1,3 );
- setfillstyle( 1, 10 );
- floodfill(x1,y1,10 );
- lineto( x1,y1 );
- }
- }
- getch();
- closegraph();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement