Guest User

Untitled

a guest
May 22nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define NR 10
  4. #define NC 10
  5.  
  6. int main()
  7. {
  8. typedef int mat[NR][NC];
  9. mat a;
  10. int b[2][3]={ {1, 2, 3}, {4, 5, 6} };
  11. int c[3][2]={ {1, 2}, {1,2}, {1,2} },
  12. d[2][2]={0};
  13. int n,m; // dimensione della matrice
  14. int i,j, //indici della matrice b c
  15. z,y;
  16.  
  17.  
  18. printf("\n Visualizzazione prima matrice\n");
  19. printf("\n");
  20.  
  21. for(i=0;i<2;i++)
  22. {
  23. for(j=0;j<3;j++)
  24. {
  25. printf(" %d",b[i][j]);
  26. }
  27. printf("\n");
  28. }
  29.  
  30. printf("\n Visualizzazione seconda matrice\n");
  31. printf("\n");
  32.  
  33. for(i=0;i<2;i++)
  34. {
  35. for(j=0;j<2;j++)
  36. {
  37. printf(" %d",c[i][j]);
  38. }
  39. printf("\n");
  40. }
  41. //prodotto delle due matrici
  42. for (i=0; i<2; i++) {
  43. for (j=0; j<2; j++) {
  44. for (z=0; z<3; z++) {
  45. d[i][j]= d[i][j]+(b[i][z]*c[z][j]);}}}
  46.  
  47. printf("\n Visualizzazione prodotto matrice\n");
  48. printf("\n");
  49.  
  50. for(i=0;i<2;i++)
  51. {
  52. for(j=0;j<2;j++)
  53. {
  54. printf(" %d",d[i][j]);
  55. }
  56. printf("\n");
  57. }
  58. printf("\n");
  59. system("pause");
  60. return 0;}
Add Comment
Please, Sign In to add comment