我必须编写一个c程序,它在不使用*运算符的情况下乘以两个矩阵。我写了一个代码,但结果不正确我认为使用while循环的东西是不正确的。我希望有人能帮帮忙。问候M
这是我的代码:
create or replace TRIGGER EDOR_IN_TRG
before INSERT OR UPDATE ON EMPLOYEES_MASTER_DETAILS
FOR EACH ROW
BEGIN
:new.EDOR := EDOR_FUNCTION(:new.DOFA, :NEW.DOB);
END;
答案 0 :(得分:1)
您有2个主要错误
multi
重置为0
而不是sum
,这是无用的matrix2[c][b]--;
#include<stdio.h>
int main(void)
{
int matrix1[4][4] = { {1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
int matrix2[4][4] = { {17,18,19,20},{21,22,23,24},{25,26,27,28},{29,30,31,32}};
int matrix3[4][4];
int a;
int b;
int c;
int multi = 0;
//Multiplication:
for (a = 0; a < 4; a++)
{
for (b = 0; b < 4; b++)
{
multi = 0;
for (c = 0; c < 4; c++)
{
int temp = matrix2[c][b];
while (temp > 0)
{
multi += matrix1[a][c];
temp--;
}
}
matrix3[a][b] = multi;
}
}
//result;
for (a = 0; a < 4; a++)
{
for (b = 0; b < 4; b++)
{
printf("%d\t", matrix3[a][b]);
}
printf("\n");
}
return 0;
}
<强>输出强>
250 260 270 280
618 644 670 696
986 1028 1070 1112
1354 1412 1470 1528