Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. double pythagoras(doublemin x, double y);
  5.  
  6. int a[] = {3, 3, 1, -1, -1, 1, -3, 0, 6};
  7. int b[] = {4, -4, 1, 1, -1, -1, 0, 4 ,9};
  8.  
  9. int main(void) {
  10.     double d;
  11.     for(int i= 0 ; i<sizeof(a) / sizeof(int) ; i++) {
  12.         d = pythagoras(a[i], b[i]);
  13.         printf("%3d, %3d, %9.5f\n", a[i], b[i], d);
  14.         }
  15.     printf("%3d, %3d, %9.5f\n", 5, 12, pythagoras(5,12));
  16.     return 0;
  17.     }
  18.  
  19. double pythagoras(double x, double y) {
  20.     sqrt(pow(x, 2) + pow(y, 2));
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement