【发布时间】:2013-02-16 13:22:31
【问题描述】:
我可以使用以下代码找到矩阵 2x2 的 det:
using System;
class find_det
{
static void Main()
{
int[,] x = { { 3, 5, }, { 5, 6 }, { 7, 8 } };
int det_of_x = x[0, 0] * x[1, 0] * x[0, 1] * x[1, 1];
Console.WriteLine(det_of_x);
Console.ReadLine();
}
}
但是当我试图找到 3x3 矩阵的 det 时,使用以下代码:
using System;
class matrix3x3
{
static void Main()
{
int[,,] x={{3,4,5},{3,5,6},{5,4,3}};
int det_of_x=x[0,0]*x[0,1]*x[0,2]*x[1,0]*x[1,1]*x[1,2]*x[2,0]*x[2,1]*x[2,2];
Console.WriteLine(det_of_x);
Console.ReadLine();
}
}
出现错误。为什么?
【问题讨论】:
-
您确定要计算行列式吗?
-
非常模糊的问题。你的编译器的错误应该至少给你一个提示,这里有什么问题。但正如其他人所说,它仍然是 2D Array,而不是 3D,删除类型中的额外 , 。
-
我不知道你在计算什么,但它也不是矩阵的行列式。 2x2 矩阵 A 的行列式是 det(A) = a11*a22 - a12*a21。