9511_workbook

solved exercises from algorithms & programming I (9511) prof. Cardozo
Index Commits Files Refs README
commit 939fcdc0a333be9a3613aae877777459aaf494d2
parent ba8ab464e58e73105795d922784146a8f0abc52a
Author: klewer-martin <martin.cachari@gmail.com>
Date:   Wed, 14 Apr 2021 23:50:03 -0300

Added ex04.c which is a little program that can compute the distance between two points in the x & y plane

Diffstat:
Aguia05/ex04.c | 26++++++++++++++++++++++++++
1 file changed, 26 insertions(+), 0 deletions(-)
diff --git a/guia05/ex04.c b/guia05/ex04.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <math.h>
+
+typedef struct {
+    float x, y;
+} r2Point_T;
+
+float dist(r2Point_T a,r2Point_T b)
+{
+    return sqrt(powf((b.x - a.x), 2) + powf((b.y - a.y), 2));
+}
+
+int main (void)
+{
+    r2Point_T a, b;
+
+    a.x = 2;
+    a.y = 3;
+
+    b.x = 3;
+    b.y = 6;
+
+    printf("The distance between A = (%.1f, %.1f) & B = (%.1f, %.1f) is:\n%.2f\n" \
+            , a.x, a.y, b.x, b.y, dist(a, b));
+    return 0;
+}