برنامه ای که ضرب دو ماتریس با ابعاد m*n و n*p را پیاده سازی میکند.

//This program calculates the product of 2 matrix.
#include <iostream.h>
#include <vector.h>
#include <conio.h>

int main()
{
    int m,n,p;
   cout<<"Enter size of tow integer matrix to get the product of them.\n";
    cout<<"Enter size of first matrix A(m*n).\n";
     cout<<"Enter m = ";
      cin>>m;
       cout<<"Enter n = ";
        cin>>n;
      vector <vector <int> > A(m, vector <int> (n,0));
       cout<<"\nEnter size of second matrix B("
           <<n<<"*p) .\n";
        cout<<"Enter p = ";
         cin>>p;
      vector <vector <int> > B(n, vector <int> (p,0));
        clrscr();
  cout<<"Enter Matrix A members:\n";
  for(int i=0;i<m;i++)
     for(int j=0;j<n;j++)
        {
          cout<<"Enter A["<<(i+1)<<"]["<<(j+1)<<"] =";
           cin>>A[i][j];
        }
 cout<<"\nEnter Matrix B members:\n";
  for(i=0;i<n;i++)
     for(int j=0;j<p;j++)
        {
          cout<<"Enter B["<<(i+1)<<"]["<<(j+1)<<"] =";
           cin>>B[i][j];
        }
      vector <vector <int> > C(m, vector <int> (p,0));
       for(i=0;i<m;i++)
         for(int k=0;k<p;k++)
           for(int j=0,sum=0;j<n;j++)
             C[i][k]+=A[i][j]*B[j][k];
    clrscr();
      for(i=0;i<m;i++)
         {
             for(int j=0;j<p;j++)
                cout<<C[i][j]<<"\t";
              cout<<endl;
          }
 return 0;
}


//end