From 376859dd6ce6e7bd79ebde3f2e2b351598e8403a Mon Sep 17 00:00:00 2001 From: MKing8992 <108593905+MKing8992@users.noreply.github.com> Date: Tue, 10 Dec 2024 21:45:22 -0700 Subject: [PATCH] Fix incorrect math formula in rectangle_center() Corrected the midpoint calculation in the function by using the proper midpoint formula: [(x2 + x1)/2, (y2 + y1)/2], rather than mistakenly calculating half the distance between points. --- 16/exercises/10/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/16/exercises/10/README.md b/16/exercises/10/README.md index 16296dc..073b595 100644 --- a/16/exercises/10/README.md +++ b/16/exercises/10/README.md @@ -38,8 +38,8 @@ int area_rectangle(struct rectangle r) { ```c struct point rectangle_center(struct rectangle r) { - return (struct point) {(r.lower_right.x - r.upper_left.x) / 2, - (r.lower_right.y - r.upper_left.y) / 2}; + return (struct point) {(r.lower_right.x + r.upper_left.x) / 2, + (r.lower_right.y + r.upper_left.y) / 2}; } ```