Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7. int x[10][10],y[10][10],z[10][10];
  8. int i,j,M1,N1,M2,N2,l,k;
  9.  
  10. cout<<"Unijeti dimenzije matrice X: "<<endl;
  11. do{
  12. cout<<"broj redova: ";
  13. cin>>N1;
  14. cout<<"broj kolona: ";
  15. cin>>M1;
  16. }
  17. while((N1>10)||(M1>10));
  18. cout<<endl;
  19.  
  20. M2=N1;
  21.  
  22. cout<<"Unijeti dimenzije matrice Y: "<<endl;
  23. do{
  24. cout<<"broj redova: ";
  25. cin>>N2;
  26. cout<<"broj kolona: ";
  27. cout<<M2;
  28. }
  29. while(N2>10);
  30. cout<<endl;
  31.  
  32.  
  33. cout<<"Unesite elemente X matrice: "<<endl;
  34. for(int i=0; i<N1; i++){
  35. cout<<endl<<"Unesite elemente niza: "<<endl;
  36. for(int j=0; j<M1; j++){
  37. cout<<"x["<<i<<"]["<<j<<"]=";
  38. cin>>x[i][j];
  39. }
  40. }
  41. cout<<endl;
  42.  
  43.  
  44. cout<<"Unesite elemente Y matrice: "<<endl;
  45. for(int i=0; i<N2; i++){
  46. cout<<endl<<"Unesite elemente niza: "<<endl;
  47. for(int j=0; j<M2; j++){
  48. cout<<"y["<<i<<"]["<<j<<"]=";
  49. cin>>y[i][j];
  50. }
  51. }
  52. cout<<endl;
  53.  
  54. //ispis matrica X i Y
  55.  
  56. cout <<"Matrica X: "<<endl;
  57. for(int i=0; i<N1; i++){
  58. for(int j=0; j<M1; j++){
  59. cout<<setw(5)<<x[i][j];
  60. }
  61. cout<<endl;
  62. }
  63. cout<<endl;
  64.  
  65.  
  66. cout <<"Matrica Y: "<<endl;
  67. for(int i=0; i<N2; i++){
  68. for(int j=0; j<M2; j++){
  69. cout<<setw(5)<<y[i][j];
  70. }
  71. cout<<endl;
  72. }
  73. cout<<endl;
  74.  
  75. //X*Y
  76. cout<<"proizvod matrica X i Y je: "<<endl;
  77.  
  78. k=N1;
  79. for(int i=0; i<N1; i++){
  80. for(int j=0; j<M2; j++){
  81.  
  82. z[i][j]=0;
  83. for(l=0; l<=k; l++){
  84. z[i][j]=z[i][j]+x[i][j]*y[i][j];
  85. }
  86. cout<<z[i][j];
  87. }
  88. cout<< endl;
  89. }
  90. return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement