dim2_0.cpp

来自「在c环境下的对数据结构进行讲解,包含有例题及答案」· C++ 代码 · 共 35 行

CPP
35
字号
//dim2_0.cpp
#include <iostream.h>	//cout
#include <conio.h>		//getch()
#include <stdlib.h>		//randomize(),random()
const int ROW=3;
const int COLUMN =4;
void main()
{ int a[ROW][COLUMN],i,j;
  //randomize()
  for (i=0;i<ROW;i++)
  for (j=0;j<COLUMN;j++)
  a[i][j]=random(100);
    cout << "各元素的标注式输出:\n";
  for (i=0;i<ROW;i++)
  { cout << "  i  j\n";
    for (j=0;j<COLUMN;j++)
    { cout <<"a["<<i<<"]["<<j<<"]=";
      cout.width(3);
      cout<< a[i][j] << endl;
    }
    cout << endl;
  }
  cout << "行列式输出:\n";
  cout << "    0  1  2  3\n";
  for (i=0;i<ROW;i++)
  { cout << i << ' ';
    for (j=0;j<COLUMN;j++)
    { cout.width(3);
      cout<< a[i][j];
    }
    cout << endl;
  }
  cout << "按任意键继续....";getch();
}

⌨️ 快捷键说明

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