fork download
  1. // Online C compiler to run C program online
  2. #include<stdio.h>
  3.  
  4.  
  5. void midPointCircleDraw(int x_centre, int y_centre, int r)
  6. {
  7. int x = r, y = 0;
  8.  
  9.  
  10. printf("(%d, %d) ", x + x_centre, y + y_centre);
  11.  
  12.  
  13. if (r > 0)
  14. {
  15. printf("(%d, %d) ", x + x_centre, -y + y_centre);
  16. printf("(%d, %d) ", y + x_centre, x + y_centre);
  17. printf("(%d, %d)\n", -y + x_centre, x + y_centre);
  18. }
  19.  
  20.  
  21. int P = 1 - r;
  22. while (x > y)
  23. {
  24. y++;
  25.  
  26.  
  27. if (P <= 0)
  28. P = P + 2*y + 1;
  29.  
  30.  
  31. else
  32. {
  33. x--;
  34. P = P + 2*y - 2*x + 1;
  35. }
  36.  
  37.  
  38. if (x < y)
  39. break;
  40.  
  41.  
  42. printf("(%d, %d) ", x + x_centre, y + y_centre);
  43. printf("(%d, %d) ", -x + x_centre, y + y_centre);
  44. printf("(%d, %d) ", x + x_centre, -y + y_centre);
  45. printf("(%d, %d)\n", -x + x_centre, -y + y_centre);
  46.  
  47.  
  48. if (x != y)
  49. {
  50. printf("(%d, %d) ", y + x_centre, x + y_centre);
  51. printf("(%d, %d) ", -y + x_centre, x + y_centre);
  52. printf("(%d, %d) ", y + x_centre, -x + y_centre);
  53. printf("(%d, %d)\n", -y + x_centre, -x + y_centre);
  54. }
  55. }
  56. }
  57.  
  58.  
  59. int main()
  60. {
  61. midPointCircleDraw(0, 0, 3);
  62. return 0;
  63. }
  64.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
(3, 0) (3, 0) (0, 3) (0, 3)
(3, 1) (-3, 1) (3, -1) (-3, -1)
(1, 3) (-1, 3) (1, -3) (-1, -3)
(2, 2) (-2, 2) (2, -2) (-2, -2)