C#中两个3*3矩阵相乘怎么写?
3个回答
展开全部
static void Main(string[] args)
{
string abc = string.Empty;
for (int i = 1; i <= 3; i++)
{
for (int j = 1; j <= 3; j++)
{
abc += string.Format("{0}*{1}={2} ", i, j, i * j);
if (j == 3)
{
Console.WriteLine(abc);
abc = string.Empty;
}
}
}
}
测试过,可以。
展开全部
class Program
{
static void Main(string[] args)
{
//Person p = new Student("张三", "女", "1234", "计算机");
//p.Print();
//C#二维数组
int[,] a = new int[3, 3];
int num = 1;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
a[i, j] = num;
Console.Write(a[i, j] + " ");
num++;
}
Console.WriteLine();
}
Console.WriteLine();
//C#交错数组 :数组的数组
int[][] arr = new int[3][];
arr[0] = new int[] { 1, 2, 3 };
arr[1] = new int[] { 4, 5, 6 };
arr[2] = new int[] { 7, 8, 9 };
for (int i = 0; i < arr.Length; i++)
{
for (int j = 0; j < arr[i].Length; j++)
{
Console.Write(arr[i][j] + " ");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
{
static void Main(string[] args)
{
//Person p = new Student("张三", "女", "1234", "计算机");
//p.Print();
//C#二维数组
int[,] a = new int[3, 3];
int num = 1;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
a[i, j] = num;
Console.Write(a[i, j] + " ");
num++;
}
Console.WriteLine();
}
Console.WriteLine();
//C#交错数组 :数组的数组
int[][] arr = new int[3][];
arr[0] = new int[] { 1, 2, 3 };
arr[1] = new int[] { 4, 5, 6 };
arr[2] = new int[] { 7, 8, 9 };
for (int i = 0; i < arr.Length; i++)
{
for (int j = 0; j < arr[i].Length; j++)
{
Console.Write(arr[i][j] + " ");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private double[] result(double[][] a,double[][] b)
{
double[] result = new double[3];
for(int i = 0 ; i < 3 ; i++)
{
for(int j = 0 ; j < 3 ; j++)
{
result[i] += a[i][j] * b[j][i];
}
}
return result;
}
{
double[] result = new double[3];
for(int i = 0 ; i < 3 ; i++)
{
for(int j = 0 ; j < 3 ; j++)
{
result[i] += a[i][j] * b[j][i];
}
}
return result;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询