Advertisement
Guest User

Untitled

a guest
May 27th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int n;
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7. printf ("podaj wymiar macierzy\n");
  8. scanf ("%d", &n);
  9.  
  10. {
  11. int i,j,k;
  12.  
  13. int macierz1[n][n], macierz2[n][n], wynik[n][n];
  14.  
  15.  
  16.  
  17.  
  18. for (i=0;i<n;i++)
  19. {
  20. for (j=0;j<n;j++)
  21. {
  22. macierz1[i][j]=0;
  23. printf("podaj wyraz macierzy pierwszej w kolumnie %d i wierszu %d\n",j+1, i+1);
  24. scanf ("%d", &macierz1[i][j]);
  25. }
  26. }
  27.  
  28. for (i=0;i<n;i++)
  29. {
  30. for (j=0;j<n;j++)
  31. {
  32. macierz2[i][j]=0;
  33. printf("podaj wyraz macierzy drugiej w kolumnie %d i wierszu %d\n",j+1, i+1);
  34. scanf ("%d", &macierz2[i][j]);
  35. }
  36. }
  37.  
  38. system("cls");
  39.  
  40.  
  41. for (i=0;i<n;i++)
  42. {
  43. for (j=0;j<n;j++)
  44. {
  45. wynik[i][j]=0;
  46. }
  47. }
  48.  
  49.  
  50. for (i=0;i<n;i++)
  51. {
  52. for (j=0;j<n;j++)
  53. {
  54. for (k=0;k<n;k++){
  55. wynik[i][j]=wynik[i][j]+macierz1[i][k]*macierz2[k][j];
  56. }
  57. }
  58. }
  59.  
  60. for (i=0;i<n;i++)
  61. {
  62. printf("[");
  63. for (j=0;j<n;j++)
  64. {
  65. printf ("%d ",wynik[i][j]);
  66.  
  67. }
  68. printf("\b]\n");
  69. }
  70.  
  71. }
  72. system("PAUSE");
  73. return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement