Advertisement
newb_ie

Untitled

Sep 16th, 2021
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2. #include "graphics.h"
  3. using namespace std;
  4.  
  5. int main() {
  6. int _driver = DETECT,gm;
  7. initgraph(&_driver,&gm,(char*)"");
  8. int cen_x,cen_y,r;
  9. cin >> cen_x >> cen_y >> r;
  10. int x = r,y = 0;
  11. vector<pair<int,int> > points;
  12. putpixel(x + cen_x,y + cen_y,WHITE);
  13. points.push_back(make_pair(x + cen_x,y + cen_y));
  14. if (r > 0) {
  15. points.push_back(make_pair(x + cen_x,-y + cen_y));
  16. points.push_back(make_pair(y + cen_x,x + cen_y));
  17. points.push_back(make_pair(-y + cen_x,x + cen_y));
  18. }
  19. int init_p = 1 - r;
  20. for (; x > y; ++y) {
  21. if (init_p <= 0) {
  22. init_p = init_p + 2 * y + 1;
  23. } else {
  24. init_p = init_p + 2 * y - 2 * x + 1;
  25. --x;
  26. }
  27. if (x < y) break;
  28. points.push_back(make_pair(x + cen_x,y + cen_y));
  29. points.push_back(make_pair(-x + cen_x,y + cen_y));
  30. points.push_back(make_pair(x + cen_x,-y + cen_y));
  31. points.push_back(make_pair(-x + cen_x,-y + cen_y));
  32. if (x !=y) {
  33. points.push_back(make_pair(y + cen_x,x + cen_y));
  34. points.push_back(make_pair(-y + cen_x,x + cen_y));
  35. points.push_back(make_pair(y + cen_x,-x + cen_y));
  36. points.push_back(make_pair(-y + cen_x,-x + cen_y));
  37. }
  38. }
  39. sort (points.begin(),points.end());
  40. for (int i = 0; i < (int) points.size(); ++i) {
  41. putpixel(points[i].first,points[i].second,WHITE);
  42. delay(100);
  43. }
  44. getch();
  45. }
  46.  
  47.  
  48. //pnot => 5 / 4 - r
  49. //pk < 0 ? pk + 1 => pk + 2 * x(k + 1) + 1
  50. //pk > 0 ? pk + 2x(k + 1) + 1 - 2yk + 1
  51.  
  52.  
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement