C# 求两个距阵相乘的结果

0

1个回答

``````using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp3_两个矩阵相乘_二维数组_
{
class Program
{
static void Main(string[] args)
{
int[,] a = new int[3, 3] { { 1, 2, 3 }, { 9, 5, 7 }, { 12, -1, 0 } }; //定义矩阵a
int[,] b = { { 8, 1, 1 }, { 0, 1, 1 }, { 0, -4, 1 } };  //定义矩阵b
int[,] c = new int[3, 3];  //动态定义矩阵c
Console.WriteLine("数组a为：");
for (int i = 0; i < 3; i++)  //输出矩阵a
{
for(int j = 0; j < 3; j++)
{
Console.Write("{0, 5:d}", a[i, j]);
}
Console.WriteLine();
}
Console.WriteLine("数组b为：");
for (int i = 0; i < 3; i++)  //输出矩阵b
{
for (int j = 0; j < 3; j++)
{
Console.Write("{0, 5:d}", b[i, j]);
}
Console.WriteLine();
}
for (int i = 0; i < 3; i++)  //进行矩阵乘法
{
for (int j = 0; j < 3; j++) {
for(int k = 0; k < 3; k++)
{
c[i, j] += a[i, k] * b[k, j];
}
}
}
Console.WriteLine("矩阵a*b后为:");
for(int i = 0; i < 3; i++)  //输出矩阵c
{
for(int j = 0; j < 3; j++)
{
Console.Write("{0 ,5:d}",c[i,j]);
}
Console.WriteLine();
}
}
}
}
``````

https://blog.csdn.net/summoxj/article/details/79938299

0

void Matrix_Mult(float **left,float **right,float **result,int m,int n,int q);rnrnvoid main()rnrn float result[3][2];rn int i;rn int j;rn int k;rn float left[3][3] = 1,2,3,4,5,6,7,8,9;rn float right[3][2] = 1,2,2,3,3,4;rnrn for(i = 0;i<3;i++)rn rn for(j = 0;j<2;j++)rn rn printf("%d\t",result[i][j]);rn rn printf("\n");rn rnrn printf("\n");rn /*Matrix_Mult(left,right,result,3,3,2);*/rn for(i = 0;i<3;i++)rn rn for(j = 0;j<2;j++)rn rn result[i][j] = 0;rn for(k = 0;k<3;k++)rn rn result[i][j] += left[i][k]*right[k][j];rn rn rn rnrn for(i = 0;i<3;i++)rn rn for(j = 0;j<2;j++)rn rn printf("%d\t",result[i][j]);rn rn printf("\n");rn rnrn system("pause");rnrnrn /*[m*n]*[n*q] = [m*q]*/rnvoid Matrix_Mult(float **left,float **right,float **result,int m,int n,int q)rnrn int i,j,k;rnrn for(i = 0;i

。。。。。。。求两个整数相乘的进位？。。。。。。。。。。。。。

//这是源代码rnrnpublic class Test1 rn rn rn rn public static void main(String[] args)rn rn rn double r = 5;rn double pai = 3.14;rn rn System.out.println(2*r*pai);rn rn rn rn rnrnrnrn//这是输出结果，31.400000000000002rn//为什么不是31.4？？？？？？？？？？？

[code=C/C++]rn float dt = pd->t - _t0;rn outPutFloat(dt);rn dt *= _gridWidth;rn outPutFloat((float)_gridWidth);rn outPutFloat(dt);rn debug::Output((int)dt);rn[/code]rn输出rn0.044975rn50.000000rn-2.248764rn-2rn0.043975rn50.000000rn-2.198791rn-2rn0.042976rn50.000000rn-2.148818rn-2rn0.041976rn50.000000rn-2.098846rn-2rn

python3 两个数组元素相乘求和，求优化
```rn def sumAndMul2List(list1, list2):rnrn result = sum([a*b for a,b in zip(list1,list2)])rnrn return resultrn```rnrn对一张图片做卷积，除了加载图片以外不能用任何库，上面这个函数跑了很长时间，请问有没有什么办法更快一点

4*4距阵求逆

String str1 = "9.99"; String str2 = "0.95"; BigDecimal num1 = new BigDecimal(str1); BigDecimal num2 = new BigDecimal(str2); 加法 BigDecimal result = num1.add(num2); 减法

Description 输入两个大小为3*3的距阵 Input 输出一个大小为3*3的距阵，矩阵每一行相邻的的两个数字之间由一个空格隔开。具体的请详见 Sample Output Output 1 2 1 2 3 3 2 1 1 1 1 1 1 1 1 2 3 1 2 3 Sample I

// PolynMultiplyPolyn.cpp : 此文件包含 &quot;main&quot; 函数。程序执行将在此处开始并结束。 // #include &quot;pch.h&quot; #include&amp;lt;stdlib.h&amp;gt; #include&amp;lt;stdio.h&amp;gt; typedef struct polyn { int expn; float coef; struct polyn * next; ...

bash-3.00\$ echo \$irn0rnbash-3.00\$ echo \$fixedrowrn10000rnbash-3.00\$ a=`\$i \* \$fixedrow`rnbash: 0: command not foundrnrn请问如何实现呢？

Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.Example 1:Input: num1 = &quot;2&quot;, num2 = &quot;3&quot; Output: &quot;6&quot;Example 2:Inp...

c 两个整数相乘

【汇编程序】两个长整数相乘
STACKS SEGMENT STACK DW 100 DUP(?) TOP LABEL WORD STACKS ENDS DATAS SEGMENT NUM1 DW 9,9,8,7,4,5,6,7,8,9 NUM2 DW 6,4,5,6,7,8,9 ；定义两个数字，首位存放num的长度，这两个数字将用于做乘法运算 S...
np.dot两个向量相乘
python里用numpy在进行向量相乘时，希望两个向量相乘得到矩阵形式。这里需要对没个向量增加一个维度才能相乘得到矩阵。python代码如下：import numpy as np a = np.array([1, 2, 3]) # shape: (3,) b = np.array([1, 2]) # shape: (2,) c = np.dot(a[:, None], b[None...

ASP里如何让两个查询结果相乘啊？

__int64 t=4819876*4819876;rn按道理结果应该是23231204655376rn运行结果却是t= -2734485688rn数据类型double,long double都用过了都不行rn请高手指教

a表rnid name agern1 张三 18rn2 李四 19rnb表rnid uid girlfreadnamern1 1 翠花rn2 1 凤姐rn3 2 石榴姐rn4 2 芙蓉姐姐rnrn要求查询结果rn张三 18 翠花,凤姐rn李四 19 石榴姐，芙蓉姐姐rnrna表的id和b表的uid关联。

package sunshine.activity; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.Vie...

context_vector = math_ops.reduce_sum( array_ops.reshape(attn_dist, [batch_size, -1, 1, 1]) * encoder_state, [1, 2]) # shape (batch_size, attn_size). encoder_state: (batch_size, attn_l...
javascript两个表单相乘问题!!!!

c# dataGridView列相乘
[img=http://img.my.csdn.net/uploads/201206/23/1340387120_8221.png][/img]rn怎写代码在dataGridView里把两列的数相乘等于第三列.即dataGridView里，在列【单价】、【数量】里填数字后，【金额】自动算出来显示。点击保存后把数据插到数据库里。【金额】=【单价】*【数量】rnrn private void button1_Click_1(object sender, EventArgs e)rn rn if (dbInsert())rn rn MessageBox.Show("新增成功！");rn rn rn private Boolean dbInsert()rn rn conn = new SqlConnection(@"Data Source=.;Initial Catalog=CS;Persist Security Info=True;User ID=sa;Password=rt");rn string strSql = "select [物品名称],[单价],[数量],([单价]*[数量]) AS [金额] from test2 ";rnrn DataTable dtShow = new DataTable();rn dtShow = (DataTable)this.dataGridView2.DataSource;rnrnrnrn tryrn rn this.conn.Open();rn SqlCommand cmd = new SqlCommand();rn cmd.Connection = conn;rn foreach (DataRow dr in dtShow.Rows)rn rnrn strSql =rn string.Format(rn "INSERT INTO test2 (入仓单编号,经手人,物品名称,单价,数量,金额) values ('0','1','2','3','4','5')",rn textBox1.Text.Trim(), textBox2.Text.Trim(), dr["物品名称"], dr["单价"], dr["数量"], dr["金额"]rn );rn cmd.CommandText = strSql;rn cmd.ExecuteNonQuery();rn rnrn this.conn.Close();rn rn catch (Exception ex)rn rn MessageBox.Show(ex.Message.ToString());rn return false;rn rn for (int i = 0; i < dataGridView2.ColumnCount; i++)rn rn dataGridView2.Columns[i].Width = 84;rn rn rn button2.Enabled = false;rn dataGridView2.Columns[0].ReadOnly = true;rn //之后添加rn rn