精华内容
下载资源
问答
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......

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

    程序清单

    #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}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bsp&nbsp&nbsp&nbspfreopen("c.dat","w",stdout);

    &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&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}

    }

    展开全文
  • C语言矩阵相乘

    2019-03-22 11:25:55
    学过线代都知道,两矩阵可以相乘的条件为第一个矩阵的列数跟第二个矩阵的行数相等即(A,B)*(B,C)=(A,C) 矩阵可以用一个二维数组保存其值 假设现在有一个2*3的矩阵,还有一个3*4的矩阵,怎么用C语言求他们的...

    学过线代都知道,两矩阵可以相乘的条件为第一个矩阵的列数跟第二个矩阵的行数相等即(A,B)*(B,C)=(A,C)

    矩阵可以用一个二维数组保存其值

    假设现在有一个2*3的矩阵,还有一个3*4的矩阵,怎么用C语言求他们的乘积矩阵呢?

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int a[100][100],b[100][100],c[100][100];
    	int x1,y1,x2,y2;
    	cin>>x1>>y1;
    	for(int i=0;i<x1;i++){
    		for(int j=0;j<y1;j++)
    		cin>>a[i][j];		//为矩阵a赋值 
    	}
    	cin>>x2>>y2;
    	for(int i=0;i<x2;i++){
    		for(int j=0;j<y2;j++)
    		cin>>b[i][j];		//为矩阵b赋值 
    	}
    	for(int i=0;i<x1;i++){
    		for(int j=0;j<y2;j++){
    			for(int k=0;k<y1;k++)
    			c[i][j]+=a[i][k]*b[k][j];		//计算所得矩阵每个位置的值 
    		}
    	}
    	for(int i=0;i<x1;i++){
    		for(int j=0;j<y2;j++)
    		cout<<c[i][j]<<" ";			//输出乘积矩阵c 
    		cout<<endl;
    	} 
    	return 0;
    }

    关键步骤就是计算乘积矩阵每个位置值的那一个循环,只要那个循环的逻辑搞清了,以后做题遇到求矩阵就可以直接拿来用

    这个简单的弟弟问题昨晚竟然让我想了半天,还是太垃圾了,继续努力啊。。。

    展开全文
  • C语言 矩阵相乘 矩阵转置 //求转置矩阵 void Transpose2(double a[][MAXSIZE], double b[][MAXSIZE], int row, int col); void Transpose1to2(double a[MAXSIZE], double b[][MAXSIZE]); //显示矩阵 void display...
  • c语言矩阵相乘

    千次阅读 2014-10-16 10:45:50
    #include ...//定义三个数组,分别存储矩阵A,B,C intm1,n1,m2,n2,i1,j1,i2,j2,i3,j3,i4,j4,k; floats[100][100]={0};//赋值使数组s元素初值全部为零 printf("请输入矩阵A行数m1,列数n1:");//输入矩阵A行
    #include<stdio.h>
    int main()
    {
    float a[100][100],b[100][100],c[100][100];//定义三个数组,分别存储矩阵A,B,C
    int m1,n1,m2,n2,i1,j1,i2,j2,i3,j3,i4,j4,k;
    float s[100][100]={0};//赋值使数组s元素初值全部为零
    printf("请输入矩阵A行数m1,列数n1:");//输入矩阵A行数,列数
    scanf("%d,%d",&m1,&n1);
    printf("请输入矩阵B行数m2,列数n2:");//输入矩阵B行数,列数
    scanf("%d,%d",&m2,&n2);
    printf("\n\n");//如果不可以相乘,下面将出现判断,在此换行,便于观看
    if(n1!=m2)
    printf("不可以相乘!!!");//判断是否可以相乘
    printf("\n\n");
    if((m1>100)||(n1>100))
    printf("数目过多!!!");//控制矩阵A元素数量在数组容纳范围内
    else
    {
    for(i1=1;i1<=m1;i1++)
    {
    for(j1=1;j1<=n1;j1++)
    {
    printf("a[%d][%d]=:",i1,j1);
    scanf("%f",&a[i1-1][j1-1]);//输入矩阵A元素
    }
    }
    }
    printf("\n");//分隔开A,B的元素输入,便于观看
    if((m2>100)||(n2>100))
    printf("数目过多!!!");
    else
    {
    for(i2=1;i2<=m2;i2++)
    {
    for(j2=1;j2<=n2;j2++)
    {
    printf("b[%d][%d]=:",i2,j2);
    scanf("%f",&b[i2-1][j2-1]);//输入矩阵B元素
    }
    }
    }
    printf("矩阵A:\n");//输出矩阵A,便于观看,检验
    for(i3=0;i3<m1;i3++)
    {
    for(j3=0;j3<n1;j3++)
    {
    printf("%f",a[i3][j3]);
    }
    printf("\n");
    }
    printf("\n");//与矩阵B的输出结果隔开,便于观看
    printf("矩阵B:\n");//输出矩阵A,便于观看,检验
    for(i4=0;i4<m2;i4++)
    {
    for(j4=0;j4<n2;j4++)
    {
    printf("%f",b[i4][j4]);
    }
    printf("\n");
    }
    printf("\n");
    printf("矩阵C=A*B:\n");
    for(i4=0;i4<m1;i4++)
    {
    for(j4=0;j4<n2;j4++)
    {
    for(k=0;k<n1;k++)
    {
    s[i4][j4]=s[i4][j4]+a[i4][k]*b[k][j4];//定义矩阵乘法,相乘时,有一个指标是一样的,都用k
    }
    c[i4][j4]=s[i4][j4];//定义矩阵乘法
    printf("%f",c[i4][j4]);
    if(j4==n2)
    printf("\n");//控制在列指标到达N时换行
    }
    }
    return0;
    }

    展开全文
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......

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

    程序清单

    #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&nbsp&nbsp&nbsp&nbsp&nbsp&nbspfor(i=0;i<3;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&n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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}

    }

    展开全文
  • C语言矩阵相乘(简单型 hhhhhhhhhhhhhhhh
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......
  • c语言矩阵相乘有错误

    2021-05-17 20:38:53
    请输入a矩阵\n"); for(m=0;m<2;m++) { for(n=0;n<4;n++) { scanf("%d",&a[m][n]); } } int b[4][3]; int t,s; printf("请输入b矩阵\n"); ...
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼程序清单#include&nbspint&nbspmain(void){&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspchar&nbsp&......
  • 实现c语言动态数组,实现矩阵相乘,实现了文件读写
  • //m[i-1]和m[i]分别为第i个矩阵的行和列(i = 1、2、3...) void Traceback(int i,int j,int **s) { if(i==j) return; Traceback(i,s[i][j],s); Traceback(s[i][j]+1,j,s); printf("Multiply A %d...
  • #编写程序计算两个矩阵的乘积,请将以下代码复制到codeblocks中,将multiply函数补充完整,程序运行正确后将所有代码(包括题目中给出的代码)复制到答题区内运行并提交。 #include <stdio.h> #define M 3 #...
  • c语言实现矩阵相乘

    2014-08-16 19:44:35
    c语言实现矩阵相乘,适用于三乘三矩阵。
  • 用计算机C语言表示矩阵相乘,个人学习C语言算法的思维,全作为参考依据
  • 矩阵相乘c语言

    2020-11-30 23:18:48
    c语言矩阵相乘1、矩阵相乘函数部分2、心得3、源程序 1、矩阵相乘函数部分 代码如下(示例): void fun(int a[10][10],int b[10][10],int m,int p,int n)//定义函数fun { int c[m][p]; int i,j,x,t; for(i=0;i&...
  • C语言实现矩阵相乘

    千次阅读 2020-03-06 16:42:28
    C语言实现两个矩阵相乘 实现代码如下 #include <stdio.h> #define cow 4 #define clo 3 void mat_mub(const int a[4][3],const int b[3][4],int c[3][3]) { int i,j,k; for(i=0;i<3;i++) { fo...
  • C语言矩阵相乘问题

    2009-03-31 21:13:17
    实现求矩阵相乘最小次数的问题,输入矩阵个数,以及各个矩阵的行数和最后一个矩阵的列数;输出MATCHAIN算法的二维数组与最小相乘次数
  • c语言矩阵相乘

    千次阅读 2019-05-06 00:52:54
    //矩阵相乘算法,最后四个参数是两个相乘的矩阵的行数和列数 void matrix_multiply(const int m, const int n, const int p, const int *a, const int *b, int *c){ for(int i=0;i;i++){ for(int j=0;j;j++){ *(c...

空空如也

空空如也

1 2 3 4 5 ... 13
收藏数 245
精华内容 98
关键字:

c语言矩阵相乘

c语言 订阅