📄 برنامه ضرب بعد از تغییر.txt
字号:
#include <iostream.h>
#include <conio.h>
void mul(int m1[20][20], int m2[20][20], int m, int n, int q)
{
int i,j,k,p[20][20];
for(i=0; i<m; i++)
for(j=0; j<q; j++)
{
p[i][j] =m1[i][0]*m2[0][j];;
for(k=1; k<n; k++)
p[i][j] += m1[i][k]*m2[k][j];
}
cout<<"\n The product: \n";
for(i=0; i<m; i++)
{
for(j=0; j<q; j++)
{
cout<<p[i][j]<<" ";
}
cout<<"\n";
}
}
main()
{
int a[20][20], b[20][20], i,j,m,n,p,q;
cout<<"Enter the row & col of matrix a:";
cin>>m>>n;
cout<<"\n Enter the element of matrix a:\n";
for(i=0; i<m; i++)
for(j=0; j<n; j++)
{
cout<<"\na["<<i+1<<"]"<<"["<<j+1<<"]:";
cin>>a[i][j];
}
cout<<"Enter the row & col of matrix b:";
cin>>p>>q;
cout<<"\n Enter the element of matrix b:\n";
for(i=0; i<p; i++)
for(j=0; j<q; j++)
{
cout<<"\nb["<<i+1<<"]"<<"["<<j+1<<"]:";
cin>>b[i][j];
}
/* Displaying Matrix1 and Matrix2 */
clrscr();
cout<<"matrix a:\n";
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
cout<<a[i][j]<<" ";
cout<<"\n";
}
cout<<"\n";
cout<<"matrix b:\n";
for(i=0; i<p; i++)
{
for(j=0; j<q; j++)
cout<<b[i][j]<<" ";
cout<<"\n";
}
if (n==p)
mul(a,b,m,n,q);
else
cout<<"mul not posible!";
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -