Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream.h>
- #include <iomanip>
- using namespace std;
- int main(){
- int x[10][10],y[10][10],z[10][10];
- int i,j,M1,N1,M2,N2,l,k;
- cout<<"Unijeti dimenzije matrice X: "<<endl;
- do{
- cout<<"broj redova: ";
- cin>>N1;
- cout<<"broj kolona: ";
- cin>>M1;
- }
- while((N1>10)||(M1>10));
- cout<<endl;
- M2=N1;
- cout<<"Unijeti dimenzije matrice Y: "<<endl;
- do{
- cout<<"broj redova: ";
- cin>>N2;
- cout<<"broj kolona: ";
- cout<<M2;
- }
- while(N2>10);
- cout<<endl;
- cout<<"Unesite elemente X matrice: "<<endl;
- for(int i=0; i<N1; i++){
- cout<<endl<<"Unesite elemente niza: "<<endl;
- for(int j=0; j<M1; j++){
- cout<<"x["<<i<<"]["<<j<<"]=";
- cin>>x[i][j];
- }
- }
- cout<<endl;
- cout<<"Unesite elemente Y matrice: "<<endl;
- for(int i=0; i<N2; i++){
- cout<<endl<<"Unesite elemente niza: "<<endl;
- for(int j=0; j<M2; j++){
- cout<<"y["<<i<<"]["<<j<<"]=";
- cin>>y[i][j];
- }
- }
- cout<<endl;
- //ispis matrica X i Y
- cout <<"Matrica X: "<<endl;
- for(int i=0; i<N1; i++){
- for(int j=0; j<M1; j++){
- cout<<setw(5)<<x[i][j];
- }
- cout<<endl;
- }
- cout<<endl;
- cout <<"Matrica Y: "<<endl;
- for(int i=0; i<N2; i++){
- for(int j=0; j<M2; j++){
- cout<<setw(5)<<y[i][j];
- }
- cout<<endl;
- }
- cout<<endl;
- //X*Y
- cout<<"proizvod matrica X i Y je: "<<endl;
- k=N1;
- for(int i=0; i<N1; i++){
- for(int j=0; j<M2; j++){
- z[i][j]=0;
- for(l=0; l<=k; l++){
- z[i][j]=z[i][j]+x[i][j]*y[i][j];
- }
- cout<<z[i][j];
- }
- cout<< endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement