返回列表 發帖
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main(void){
  5.    
  6.     int n = 0;
  7.    
  8.     cout << "請輸入矩陣大小:" << endl;
  9.     cin >> n;
  10.    
  11.     int a[n][n];
  12.     int b[n][n];
  13.    
  14.     for(int i = 0; i < n; i++){
  15.             for(int j = 0; j < n; j++){
  16.                     a[i][j] = (rand()%9)+1;
  17.                     cout << a[i][j] << " ";
  18.                     b[i][j] = (rand()%9)+1;
  19.                     cout << b[i][j] << " ";
  20.             }
  21.     }
  22.     for(int i = 0; i < n; i++){
  23.             for(int j = 0; j < n; j++){
  24.                     cout << a[i][j] * b[i][j] << " ";
  25.             }
  26.     }
  27.      
  28.    
  29.     system("pause");
  30.     return 0;
  31. }
複製代碼

TOP

返回列表