Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- #include "graphics.h"
- using namespace std;
- int main() {
- int _driver = DETECT,gm;
- initgraph(&_driver,&gm,(char*)"");
- int cen_x,cen_y,r;
- cin >> cen_x >> cen_y >> r;
- int x = r,y = 0;
- vector<pair<int,int> > points;
- putpixel(x + cen_x,y + cen_y,WHITE);
- points.push_back(make_pair(x + cen_x,y + cen_y));
- if (r > 0) {
- points.push_back(make_pair(x + cen_x,-y + cen_y));
- points.push_back(make_pair(y + cen_x,x + cen_y));
- points.push_back(make_pair(-y + cen_x,x + cen_y));
- }
- int init_p = 1 - r;
- for (; x > y; ++y) {
- if (init_p <= 0) {
- init_p = init_p + 2 * y + 1;
- } else {
- init_p = init_p + 2 * y - 2 * x + 1;
- --x;
- }
- if (x < y) break;
- points.push_back(make_pair(x + cen_x,y + cen_y));
- points.push_back(make_pair(-x + cen_x,y + cen_y));
- points.push_back(make_pair(x + cen_x,-y + cen_y));
- points.push_back(make_pair(-x + cen_x,-y + cen_y));
- if (x !=y) {
- points.push_back(make_pair(y + cen_x,x + cen_y));
- points.push_back(make_pair(-y + cen_x,x + cen_y));
- points.push_back(make_pair(y + cen_x,-x + cen_y));
- points.push_back(make_pair(-y + cen_x,-x + cen_y));
- }
- }
- sort (points.begin(),points.end());
- for (int i = 0; i < (int) points.size(); ++i) {
- putpixel(points[i].first,points[i].second,WHITE);
- delay(100);
- }
- getch();
- }
- //pnot => 5 / 4 - r
- //pk < 0 ? pk + 1 => pk + 2 * x(k + 1) + 1
- //pk > 0 ? pk + 2x(k + 1) + 1 - 2yk + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement