- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main(void){
-
- int n = 0;
-
- cout << "請輸入矩陣大小:" << endl;
- cin >> n;
-
- int a[n][n];
- int b[n][n];
-
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- a[i][j] = (rand()%9)+1;
- cout << a[i][j] << " ";
- b[i][j] = (rand()%9)+1;
- cout << b[i][j] << " ";
- }
- }
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- cout << a[i][j] * b[i][j] << " ";
- }
- }
-
-
- system("pause");
- return 0;
- }
複製代碼 |