阿摩線上測驗 登入

申論題資訊

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

題組內容

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

申論題內容

(b) If the function call is matrix_addition(C, A, B), what is the function heading of “matrix_addition”? Note that a function heading includes the return type, function name, and its parameters. Use void as the return type. (5%).

詳解 (共 1 筆)

詳解 提供者:hchungw

Given the function call matrix_addition(C, A, B), where C, A, and B are presumably 2-D matrices of 3 rows and 3 columns containing double-precision floating-point numbers, and assuming the goal is to perform matrix addition where C=A+B, the function heading for matrix_addition using void as the return type would be as follows:

 
void matrix_addition(double C[3][3], double A[3][3], double B[3][3]);

This function heading indicates that matrix_addition takes three parameters, all of which are 2-D arrays (matrices) with 3 rows and 3 columns containing double-precision floating-point numbers. The matrices A and B are the matrices to be added, and the result is stored in matrix C. Since the matrices are modified and the results are stored directly in one of the parameters (matrix C), there's no need for a return value, hence the use of void as the return type.

 

給定函數調用matrix_addition(C, A, B),其中C, A, 和B推定為包含雙精度浮點數的3行3列2維矩陣,假設目標是執行矩陣加法,其中 C=A+B,則使用void作為返回類型的matrix_addition函數標頭如下:

 
void matrix_addition(double C[3][3], double A[3][3], double B[3][3]);

此函數標頭表明matrix_addition接受三個參數,所有這些參數都是包含雙精度浮點數的3行3列的2維陣列(矩陣)。矩陣A和B是要相加的矩陣,結果存儲在矩陣C中。由於矩陣被修改且結果直接存儲在其中一個參數(矩陣C)中,因此無需返回值,因此使用void作為返回類型。