Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <graphics.h>
  4. using namespace std;
  5. int main()
  6. {
  7.     float x, y, x1, y1, R;
  8.     float i = 0;
  9.     cout <<"write R: ";
  10.     cin >> R;
  11.    
  12.     initwindow(100*R+100,100*R+100); //oci koordinat
  13.     setfillstyle(1,15);
  14.     line(0,50*R+50,100*R+100,50*R+50);
  15.     line(50*R+50,0,50*R+50,100*R+100);
  16.     line(50*R+50,0,50*R+40,10);
  17.     line(50*R+50,0,50*R+60,10);
  18.     line(100*R+100,50*R+50,100*R+90,50*R+60);
  19.     line(100*R+100,50*R+50,100*R+90,50*R+40);
  20.    
  21.     setcolor(15); //krug
  22.     circle(50*R+50,50*R+50,R*50);
  23.     circle(50*R+50,50*R+50,R*50+1);
  24.  
  25.    
  26.     setfillstyle(1,15); //ogranichenie
  27.     line(50,50*R+50,50*R+50,50);
  28.    
  29.     setfillstyle(1,8);
  30.     floodfill(50,100*R+90,15);  //zalivka oblostei
  31.     setfillstyle(1,8);
  32.     floodfill(50+25*R,50+25*R,15);
  33.     setfillstyle(1,8);
  34.     floodfill(75*R+75,75*R+75,15);
  35.    
  36.     while (i > 0)
  37.     {
  38.         cout <<"write x: ";
  39.         cin >> x;
  40.         cout <<"write y: ";
  41.         cin >> y;
  42.    
  43.         if (((x >= 0) and (y <= 0) and (x*x + y*y <= R*R)) or ((x*x + y*y <= R*R) and (x <= 0) and (y >= 0) and (x <= y - R)) or ((x*x + y*y >= R*R) and (x <= 0) and (y <= 0)))
  44.         {
  45.             x1 =  50*R + 50 + x*50; // tochki
  46.             y1 = 50*R +50 - y*50;
  47.             setcolor(10);
  48.             circle(x1,y1,3);
  49.             setfillstyle(1,10);
  50.             floodfill(x1,y1,10);
  51.             cout << "vi popali " <<"\n";
  52.         }
  53.         else
  54.         {
  55.             x1 =  50*R + 50 + x*50; //tochki
  56.             y1 = 50*R +50 - y*50;
  57.             setcolor(12);
  58.             circle(x1,y1,3);
  59.             setfillstyle(1,12);
  60.             floodfill(x1,y1,12);
  61.             cout << "no:( " <<"\n";
  62.         }
  63.         i -= 1;
  64.     }
  65.     getch();
  66.     closegraph();
  67.     return 0;  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement