⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex05-06.cpp

📁 数据结构常用算法合集
💻 CPP
字号:
//EX05-06.cpp
#include <iostream.h>	//cout,cin
#include <conio.h>		// getch()
#include <stdlib.h>	//random
const int M=5;
const int N=4;
const int P=3;
void main()
{ int a[M][N],b[N][P],c[M][P],i,j;
  for (i=0;i<M;i++)		//get a data
  for (j=0;j<N;j++)
  a[i][j]=random(10);	//get random data
  for (i=0;i<N;i++)		//get b data
  for (j=0;j<P;j++)
  b[i][j]=random(10);	//get random data
  cout << "a array as followings:\n";
  for (i=0;i<M;i++)
  { for (j=0;j<N;j++)
    { cout.width(3);
      cout<<a[i][j];
    }
    cout << endl;
  }
  cout << "b array as followings:\n";
  for (i=0;i<N;i++)
  { for (j=0;j<P;j++)
    { cout.width(3);
      cout<<b[i][j];
    }
    cout << endl;
  }
  // do the product
  for (i=0;i<M;i++)
  for (j=0;j<P;j++)
  { c[i][j]=0;
    for (int k=0;k<N;k++)
    c[i][j]+=a[i][k]*b[k][j];
  }
  cout << "c array as followings:\n";
  for (i=0;i<M;i++)
  { for (j=0;j<P;j++)
    { cout.width(5);
      cout<<c[i][j];
    }
    cout << endl;
  }
  getch();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -