乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      113.實(shí)矩陣乘法運(yùn)算

       C語言與CPP編程 2022-05-05 發(fā)布于安徽
      #include "stdio.h"
      #define MAX 255
      void MatrixMul(a,b,m,n,k,c)  /*實(shí)矩陣相乘*/
      int m,n,k; /*m:矩陣A的行數(shù), n:矩陣B的行數(shù), k:矩陣B的列數(shù)*/
      double a[],b[],c[]; /*a為A矩陣, b為B矩陣, c為結(jié)果,即c = AB */
      {
      	int i,j,l,u;
      	/*逐行逐列計(jì)算乘積*/
      	for (i=0; i<=m-1; i++)
      		for (j=0; j<=k-1; j++)
      		{
      			u=i*k+j; c[u]=0.0;
      			for (l=0; l<=n-1; l++)
      				c[u]=c[u]+a[i*n+l]*b[l*k+j];
      		}
      	return;
      }
      
      
      
      main()
      {
      	int i,j,m,n,k;
      	double A[MAX];
      	double B[MAX];
      	double C[MAX];
      	for(i=0;i<MAX;i++)
      		C[i]=1.0;
      	clrscr();
      	puts("This is a real-matrix-multiplication program.\n");
      	puts("It calculate the two matrixes C(m*k)=A(m*n)B(n*k).\n");
      	printf(" >> Please input the number of rows in A, m= ");
      	scanf("%d",&m);
      	printf(" >> Please input the number of cols in A, n= ");
      	scanf("%d",&n);
      	printf(" >> Please input the number of cols in B, k= ");
      	scanf("%d",&k);
      	printf(" >> Please input the %d elements in A one by one:\n",m*n);
      	for(i=0;i<m*n;i++)
      		scanf("%lf",&A[i]);
      	printf(" >> Please input the %d elements in B one by one:\n",n*k);
      	for(i=0;i<n*k;i++)
      		scanf("%lf",&B[i]);
      
      	MatrixMul(A,B,m,n,k,C); /*計(jì)算C的結(jié)果*/
      	/*格式化輸出結(jié)果*/
      	printf("\n >> The result of C(%d*%d)=A(%d*%d)B(%d*%d) is:\n",m,k,m,n,n,k);
      	for (i=0; i<m; i++)
      	{
      		for (j=0; j<k; j++)
      			printf("%10.5f    ",C[i*k+j]);
      		printf("\n");
      	}
      	printf("\n Press any key to quit...\n");
      	getch();
      	return 0;
      }

        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多