Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- double pythagoras(doublemin x, double y);
- int a[] = {3, 3, 1, -1, -1, 1, -3, 0, 6};
- int b[] = {4, -4, 1, 1, -1, -1, 0, 4 ,9};
- int main(void) {
- double d;
- for(int i= 0 ; i<sizeof(a) / sizeof(int) ; i++) {
- d = pythagoras(a[i], b[i]);
- printf("%3d, %3d, %9.5f\n", a[i], b[i], d);
- }
- printf("%3d, %3d, %9.5f\n", 5, 12, pythagoras(5,12));
- return 0;
- }
- double pythagoras(double x, double y) {
- sqrt(pow(x, 2) + pow(y, 2));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement