您现在的位置是:首页 > 正文

c语言中矩阵ab相乘,c语言矩阵相乘

2024-04-01 06:40:34阅读 6

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

程序清单

#include&nbsp

int&nbspmain(void)

{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&nbsp&nbsp&nbspa[2][3];

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&nbsp&nbsp&nbspb[3][3];

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&nbsp&nbsp&nbspc[2][3];

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspregister&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspint&nbsp&nbsp&nbsp&nbsp&nbspi;

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspregister&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspint&nbsp&nbsp&nbsp&nbsp&nbspj;

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspfreopen("a.dat","r",stdin);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspfor(i=0;i<2;i++)

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspfor(j=0;j<3;j++)

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspscanf("%d",&a[i][j]);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspfreopen("b.dat","r",stdin);

&nbsp&nbsp&nb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i++)

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspfor(j=0;j<3;j++)

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspprintf("%d&nbsp",c[i][j]);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspprintf("\n");

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}

}

网站文章

  • 如何在Android应用程序中实现后台服务?

    注意,服务在后台执行时,它并不会自动停止。如果你想停止服务,需要在代码中显式地调用stopService()方法。另外,如果你想让服务在应用程序退出后仍然运行,你需要将服务设置为前台服务,这可以通过调...

    2024-04-01 06:40:26
  • ES6 入门—ES6 迭代器

    ES6 入门—ES6 迭代器

    迭代器,是 ES6 引入的一种新的遍历机制,主要讲解的是 Iterator 、迭代过程、可迭代的数据结构。

    2024-04-01 06:40:18
  • 计算机视觉学习:第一天

    计算机视觉学习:第一天编程语言:Python代码引自 《深度学习与计算机视觉》import matplotlib.pyplot as pltimport numpy as npfrom mpl_too...

    2024-04-01 06:39:38
  • 谈谈java中的WeakReference

    谈谈java中的WeakReference

    Java语言中为对象的引用分为了四个级别,分别为 强引用 、软引用、弱引用、虚引用。本文只针对java中的弱引用进行一些分析,如有出入还请多指正。在分析弱引用之前,先阐述一个概念:什么是对象可到达和对象不可到达状态。其实很简单,我举个例子:现在有如下两个类class A class B,在JVM上生成他们两个类的实例分别为 instance a  instance b有如下

    2024-04-01 06:39:32
  • 多图--两种方法----C++改变常成员函数(Const)的值

    多图--两种方法----C++改变常成员函数(Const)的值

    常成员函数: &lt;1&gt; 成员函数后面加了const。&lt;2&gt; 不能修改类的成员,不能对它赋值,只是一个可读函数。提高程序的可读性,可靠性。如图,fun函数是常成员函数: 将i的值改为100,则会报错: 第一种修改方法:用mutable关键字: 看效果:第二种修改方法:用this指针: 有什么问题欢迎留言!~~~~...

    2024-04-01 06:39:25
  • java wildcard_java泛型 wildcard

    import java.util.ArrayList;import java.util.List;public class WildCard {public static void main(Stri...

    2024-04-01 06:38:42
  • hbase对HDFS开启短路读功能

    1.增加短路读路径mkdir /var/lib/hadoop-hdfs chmod 775 /var/lib/hadoop-hdfschown hdfs:root -R /var/lib/hadoop...

    2024-04-01 06:38:30
  • 排序算法之快排

    快速排序是常见排序算法中速度最快的,最好的和平均时间复杂度为O(nlogn),空间复杂度为O(nlogn),是一个不稳定的排序方法。其实现过程如下:1、取出第开始的元素作为测试值,先从右侧开始遍历;2、将测试值与右侧值比较,右侧值若大于等于测试值,则继续左移再与测试值比较。若右侧遍历到测试值的下一个元素仍找不到小于测试值的元素,则证明测试值为当前序列中最小的元素,其位置不变,跳过步骤3

    2024-04-01 06:37:46
  • webstorm 配置连接Linux环境的docker服务

    webstorm 配置连接Linux环境的docker服务

    可以看到docker.service的路径:/usr/lib/systemd/system/docker.service。2)输入命令【systemctl status docker.service】...

    2024-04-01 06:37:39
  • 专题:Secure Shell软件(简称SSH的)

    Xshell、MobaXterm等5款主流SSH客户端对比如今大多数的网民用户都是使用的Windows操作系统,但如果想要连接Linux服务器来进行文件之间的传送,那就需要一个Secure Shell...

    2024-04-01 06:37:31