我能够使用这个代码,找出矩阵2×2的DET:如何找到在C#矩阵3×3的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();
}
}
它出错。为什么?
什么是错误? – 2013-02-16 13:26:17
你确定你计算行列式吗? – qben 2013-02-16 13:27:27
可怕的模糊问题。编译器的错误应该让你知道这里有什么问题。但正如其他人所说的那样,它仍然是一个二维阵列,而不是一个3D,在类型中删除额外的。 – 2013-02-16 13:27:45