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

📄 matrix1_cpp.htm

📁 illustrate using std and stl libriry
💻 HTM
字号:
<html>



<head>

<meta http-equiv="Content-Type" content="text/html">

<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">

<title>matrix1.cpp</title>

</head>



<body>



<pre>/*	matrix1.cpp



        Multiplication of matrixes.

        Static arrays, DIM=500.



	(C) R.N.Shakirov, IMach of RAS(UB), 1998 - 2000

	All Rights Reserved.

*/

#include &lt;fstream.h&gt;

<b>#define  DIM 500</b>



int	main	(int argc, char **argv)

{

  if (argc &lt; 3) return 1;

  <b>static int m1 [DIM] [DIM];</b>

  <b>static int m2 [DIM] [DIM];</b>

  <b>static int m3 [DIM] [DIM];</b>

  int i,j,k,dim = 0;



  // Input



  ifstream fin  (argv [1]);

  if (!fin) return 1;

  fin &gt;&gt; dim;

  <b>if (dim &gt; DIM) return 1;</b>



  for (i = 0; i &lt; dim; i++)

    for (j = 0; j &lt; dim; j++)

      fin &gt;&gt; m1 [i] [j];



  for (i = 0; i &lt; dim; i++)

    for (j = 0; j &lt; dim; j++)

      fin &gt;&gt; m2 [i] [j];



  // Multiplication



  for (i = 0; i &lt; dim; i++)

    for (j = 0; j &lt; dim; j++)

    {

      int sum = 0;

      for (k = 0; k &lt; dim; k++)

        sum += m1 [i] [k] * m2 [k] [j];

      m3 [i] [j] = sum;

    }



  // Output 



  ofstream fout (argv [2]);

  if (!fout) return 1;

  for (i = 0; i &lt; dim; i++)

  {

    for (j = 0; j &lt; dim; j++)

      { fout.width (6); fout &lt;&lt; m3 [i] [j]; }

    fout &lt;&lt; '\n';

  }



  return 0;

}

</pre>

</body>

</html>

⌨️ 快捷键说明

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