Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdint.h>
  4. #include <inttypes.h>
  5. #include <time.h>
  6. #include <string.h>
  7. #include <math.h>
  8.  
  9. extern float dot_product(int n, const float *x, const float *y);
  10.  
  11. int main() {
  12.     int n;
  13.     scanf("%d", &n);
  14.     float *x = calloc(n, sizeof(float));
  15.     float *y = calloc(n, sizeof(float));
  16.     for (int i = 0; i < n; i++) {
  17.         scanf("%f", &(x[i]));
  18.     }
  19.     for (int i = 0; i < n; i++) {
  20.         scanf("%f", &(y[i]));
  21.     }
  22.     float res = dot_product(n, x, y);
  23.     printf("%f\n", res);
  24.     free(x);
  25.     free(y);
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement