Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #define M 3
  3. #define N 2
  4.  
  5. void prodotto(double *mat,double *A,double *array){
  6. for (int i=0;i<M;i++){
  7. double somma=0;
  8. for (int j=0;j<N;j++){
  9. somma += (*(mat+N*i+j))*(*(A+j));
  10. }
  11. *(array+i)=somma;
  12.  
  13. }
  14. return;
  15. }
  16.  
  17.  
  18.  
  19.  
  20. int main(){
  21. double mat[M][N];
  22. double A[N]={2,3};
  23. double array[M];
  24. for (int i=0;i<M;i++){
  25. for (int j=0;j<N;j++){
  26. printf("Inserisci mat[%d][%d]= ",i,j);
  27. scanf("%lf",mat+N*i+j);
  28.  
  29. }
  30. }
  31. prodotto(mat,A,array);
  32. printf("\n");
  33. for (int k=0;k<M;k++){
  34. printf("%lf",array[k]);
  35. printf("\n");
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement