Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /*
- 1 0 1 0 2 0 1 1 2 0
- 2 1 0 1 1 0 => 2 1 5 0
- 0 1 0 1 1 0
- */
- int main()
- {
- //int a[3][2], b[2][4],
- int m, n, p;
- cout<<"Prima matrice:"<<endl;
- cout<<"m="; cin>>m;
- cout<<"n="; cin>>n;
- int a[m][n];
- for (int i=0; i<m; i++){
- for (int j=0; j<n; j++)
- cin>>a[i][j];
- }
- cout<<"A doua matrice:"<<endl;
- cout<<"p="; cin>>p;
- int b[n][p];
- for (int i=0; i<n; i++){
- for (int j=0; j<p; j++)
- cin>>b[i][j];
- }
- int c[m][p];
- for (int i=0; i<m; i++){
- for (int j=0; j<p; j++){
- c[i][j]=0;
- for (int k=0; k<n; k++){
- c[i][j]+=(a[i][k]*b[k][j]);
- }
- }
- }
- cout<<"=============="<<endl;
- for (int i=0; i<m; i++){
- for (int j=0; j<p; j++)
- cout<<c[i][j]<<" ";
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement