9511_workbook

solved exercises from algorithms & programming I (9511) prof. Cardozo
Index Commits Files Refs README
guia05/ex04.c (392B)
   1 #include <stdio.h>
   2 #include <math.h>
   3 
   4 typedef struct {
   5     float x, y;
   6 } r2Point_T;
   7 
   8 float dist(r2Point_T a,r2Point_T b)
   9 {
  10     return sqrt(powf((b.x - a.x), 2) + powf((b.y - a.y), 2));
  11 }
  12 
  13 int main (void)
  14 {
  15     r2Point_T a, b;
  16 
  17     a.x = 2;
  18     a.y = 3;
  19 
  20     b.x = 3;
  21     b.y = 6;
  22 
  23     printf("The distance between A = (%.1f, %.1f) & B = (%.1f, %.1f) is:\n%.2f\n" \
  24             , a.x, a.y, b.x, b.y, dist(a, b));
  25     return 0;
  26 }