主题:数组阶乘
数组阶乘输出时只有第一排数,后面就不知什么??为什么会这样??请教??请细说!谢谢哦!!
#include<iostream>
using namespace std;
int matrix_multi(double a[][5],double b[][3], double c[][3],int l,int m,int n)
{
int i,j,k;
for(i=0;i<1;i++)
for(j=0;j<n;j++)
{
c[i][j]=0;
for(k=0;k<m;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
return c[i][j];
}
int main()
{
double a[4][5]={
1.0, 3.0, -2.0, 0.0, 4.0,
-2.0, -1.0, 5.0, -7.0, 2.0,
0.0, 8.0, 4.0, 1.0, -5.0,
3.0, -3.0, 2.0, -4.0, 1.0
};
double b[5][3]=
{
4.0, 5.0, -1.0,
2.0, -2.0, 6.0,
7.0, 8.0, 1.0,
0.0, 3.0, -5.0,
9.0, 8.0, -6.0
};
double c[4][3];
matrix_multi(a,b,c,4,5,3);
cout<<"The result is c="<<endl;
for(int i=0;i<4;i++)
{
for(int j=0;j<3;j++)
cout<<c[i][j]<<" ";
cout<<endl;
}
return 0;
}
#include<iostream>
using namespace std;
int matrix_multi(double a[][5],double b[][3], double c[][3],int l,int m,int n)
{
int i,j,k;
for(i=0;i<1;i++)
for(j=0;j<n;j++)
{
c[i][j]=0;
for(k=0;k<m;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
return c[i][j];
}
int main()
{
double a[4][5]={
1.0, 3.0, -2.0, 0.0, 4.0,
-2.0, -1.0, 5.0, -7.0, 2.0,
0.0, 8.0, 4.0, 1.0, -5.0,
3.0, -3.0, 2.0, -4.0, 1.0
};
double b[5][3]=
{
4.0, 5.0, -1.0,
2.0, -2.0, 6.0,
7.0, 8.0, 1.0,
0.0, 3.0, -5.0,
9.0, 8.0, -6.0
};
double c[4][3];
matrix_multi(a,b,c,4,5,3);
cout<<"The result is c="<<endl;
for(int i=0;i<4;i++)
{
for(int j=0;j<3;j++)
cout<<c[i][j]<<" ";
cout<<endl;
}
return 0;
}