阿摩線上測驗 登入

申論題資訊

試卷:110年 - 110-2 國立清華大學期末考試題_電機工程學系:計算機程式設計#112945
科目:程式設計
年份:110年
排序:0

題組內容

2. (10%) Answer the following questions briefly.

申論題內容

(a) Consider a program that requires matrix operations, C=A+B, where A, B, and C are all 2-D matrices of 3 rows and 3 columns of double-precision floating-point numbers. How do we declare them using the traditional 2-D array in C++? Since the declarations of A, B, and C are similar, you only need to declare matrix A without initialization as an example. (5%)

詳解 (共 1 筆)

詳解 提供者:hchungw
In C++, you can declare a 2-D array for matrix operations like A = B + C, where A, B, and C are matrices with 3 rows and 3 columns containing double-precision floating-point numbers, using the traditional 2-D array syntax. For matrix A, without initializing it, you would declare it as follows:
cpp
Copy code
double A[3][3];
This declaration creates a 2-dimensional array, A, with 3 rows and 3 columns, where each element of the array is of type double. Similar declarations would be made for matrices B and C if they are also 3x3 matrices of double-precision floating-point numbers.
在C++中,如果您需要進行矩陣操作,如A = B + C,其中A、B和C都是包含雙精度浮點數的3行3列的2維矩陣,您可以使用傳統的2維陣列語法來聲明。對於矩陣A,不初始化的聲明方式如下:

double A[3][3];
這樣的聲明創建了一個2維陣列A,有3行3列,其中每個元素的類型都是double。如果B和C矩陣也是3x3的雙精度浮點數矩陣,則會以類似的方式進行聲明。