#include <stdio.h>
#include <math.h>
void plotCirclePoints(int xc, int yc, int x, int y) {
printf("(%d, %d)\n", xc
+ x
, yc
+ y
); printf("(%d, %d)\n", xc
- x
, yc
+ y
); printf("(%d, %d)\n", xc
+ x
, yc
- y
); printf("(%d, %d)\n", xc
- x
, yc
- y
); printf("(%d, %d)\n", xc
+ y
, yc
+ x
); printf("(%d, %d)\n", xc
- y
, yc
+ x
); printf("(%d, %d)\n", xc
+ y
, yc
- x
); printf("(%d, %d)\n", xc
- y
, yc
- x
); }
void midpointCircle(int xc, int yc, int r) {
int x = 0, y = r;
int p = 1 - r;
plotCirclePoints(xc, yc, x, y);
while (x < y) {
x++;
if (p < 0) {
p += 2 * x + 1;
} else {
y--;
p += 2 * x - 2 * y + 1;
}
plotCirclePoints(xc, yc, x, y);
}
}
int main() {
int xc, yc, r;
printf("Enter center of the circle (xc, yc): "); scanf("%d %d", &xc
, &yc
); printf("Enter radius of the circle: "); midpointCircle(xc, yc, r);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+Cgp2b2lkIHBsb3RDaXJjbGVQb2ludHMoaW50IHhjLCBpbnQgeWMsIGludCB4LCBpbnQgeSkgewogICAgcHJpbnRmKCIoJWQsICVkKVxuIiwgeGMgKyB4LCB5YyArIHkpOwogICAgcHJpbnRmKCIoJWQsICVkKVxuIiwgeGMgLSB4LCB5YyArIHkpOwogICAgcHJpbnRmKCIoJWQsICVkKVxuIiwgeGMgKyB4LCB5YyAtIHkpOwogICAgcHJpbnRmKCIoJWQsICVkKVxuIiwgeGMgLSB4LCB5YyAtIHkpOwogICAgcHJpbnRmKCIoJWQsICVkKVxuIiwgeGMgKyB5LCB5YyArIHgpOwogICAgcHJpbnRmKCIoJWQsICVkKVxuIiwgeGMgLSB5LCB5YyArIHgpOwogICAgcHJpbnRmKCIoJWQsICVkKVxuIiwgeGMgKyB5LCB5YyAtIHgpOwogICAgcHJpbnRmKCIoJWQsICVkKVxuIiwgeGMgLSB5LCB5YyAtIHgpOwp9Cgp2b2lkIG1pZHBvaW50Q2lyY2xlKGludCB4YywgaW50IHljLCBpbnQgcikgewogICAgaW50IHggPSAwLCB5ID0gcjsKICAgIGludCBwID0gMSAtIHI7CiAgICBwbG90Q2lyY2xlUG9pbnRzKHhjLCB5YywgeCwgeSk7CiAgICB3aGlsZSAoeCA8IHkpIHsKICAgICAgICB4Kys7CiAgICAgICAgaWYgKHAgPCAwKSB7CiAgICAgICAgICAgIHAgKz0gMiAqIHggKyAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHktLTsKICAgICAgICAgICAgcCArPSAyICogeCAtIDIgKiB5ICsgMTsKICAgICAgICB9CiAgICAgICAgcGxvdENpcmNsZVBvaW50cyh4YywgeWMsIHgsIHkpOwogICAgfQp9CgppbnQgbWFpbigpIHsKICAgIGludCB4YywgeWMsIHI7CiAgICBwcmludGYoIkVudGVyIGNlbnRlciBvZiB0aGUgY2lyY2xlICh4YywgeWMpOiAiKTsKICAgIHNjYW5mKCIlZCAlZCIsICZ4YywgJnljKTsKICAgIHByaW50ZigiRW50ZXIgcmFkaXVzIG9mIHRoZSBjaXJjbGU6ICIpOwogICAgc2NhbmYoIiVkIiwgJnIpOwogICAgbWlkcG9pbnRDaXJjbGUoeGMsIHljLCByKTsKICAgIHJldHVybiAwOwp9Cg==
Enter center of the circle (xc, yc): Enter radius of the circle: (0, 5)
(0, 5)
(0, -5)
(0, -5)
(5, 0)
(-5, 0)
(5, 0)
(-5, 0)
(1, 5)
(-1, 5)
(1, -5)
(-1, -5)
(5, 1)
(-5, 1)
(5, -1)
(-5, -1)
(2, 5)
(-2, 5)
(2, -5)
(-2, -5)
(5, 2)
(-5, 2)
(5, -2)
(-5, -2)
(3, 4)
(-3, 4)
(3, -4)
(-3, -4)
(4, 3)
(-4, 3)
(4, -3)
(-4, -3)
(4, 3)
(-4, 3)
(4, -3)
(-4, -3)
(3, 4)
(-3, 4)
(3, -4)
(-3, -4)