포인터를 이용하여 행렬의 곱셈 출력하는 프로그램 질문입니다.
하랑
질문 제목 :
포인터를 이용하여 행렬의 곱셈을 출력하는 프로그램 질문입니다.
- 표시한 부분에서 에러가 나는 데 어떻게 고쳐야 할 지 모르겠습니다. 고민을 해봐도 답이 안나와서...
질문 내용 :
#include stdio.h
#define row 3
#define col 3
void print(int *a, int row, int col);
void array_multi(int *a, int *b, int *c, int row, int col);
int main(void)
{
int a[row][col]={
{3,0,1},
{1,2,5},
{6,7,-1}
};
int b[row][col]={
{-2,1,3},
{5,0,5},
{0,7,-3}
};
int c[row][col]={0};
array_multi(&a[0][0],&b[0][0],&c[0][0],row,col);
print(&c[0][0],row,col);
return 0;
}
void array_multi(int *a, int *b, int *c, int row, int col)
{
int i, j, temp;
for(i=0;irow;i++)
{
for(j=0;jcol;j++)
{
}
for(temp=0;tempcol;temp++)
*c[i][j]=(*a[i][temp])*(*b[temp][j])+(*c[i][j]); - 요 부분에서 에러가 납니다.
}
}
void print(int *a, int row, int col)
{
int i,j;
for(i=0;irow;i++)
{
for(j=0;jcol;j++)
{
printf(%3d,*c[i][j]);
}
}
printf(\n);
}