matrix mulmat (const matrix & mat, int scalar);//矩陣的數乘
int getmatvalue (const matrix & mat, int row, int col); //獲取行列座標為row和col位置的矩陣元素的值
int setmatvalue (const matrix & mat, int row, int col, int scalar);
//將行列座標為row和col位置的矩陣元素的值設定為scalar
void releasemat(matrix & m);//釋放矩陣元素的空間
二、演算法分析
1.建立結構體
struct matrix
;二維陣列的實質為一維陣列,因此可以當做一維陣列處理更簡便。
2.函式的實現
矩陣的建立(三個過載函式)
matrix createmat (int rows, int cols)
matrix createmat (int rows, int cols, const int scalar)
matrix createmat (int rows, int cols, const int data)
矩陣的輸出
void outputmat(const matrix & mat)//矩陣的輸出
}矩陣的複製
void copymat(const matrix & source, matrix & target) //把矩陣source複製到矩陣target
}else
}}矩陣的轉置
matrix transmat (const matrix & mat)// 矩陣的轉置
return m;
}矩陣的加法
matrix addmat (const matrix & mat1, const matrix & mat2)//矩陣的加法
矩陣的減法
matrix submat (const matrix & mat1, const matrix & mat2)//矩陣的減法
return m;
}矩陣的數乘
matrix mulmat (const matrix & mat, int scalar)//矩陣的數乘
獲取指定行列的元素值
int getmatvalue (const matrix & mat, int row, int col) //獲取行列座標為row和col位置的矩陣元素的值
將指定行列的元素賦值
int setmatvalue (matrix & mat, int row, int col, int scalar)
//將行列座標為row和col位置的矩陣元素的值設定為scalar
釋放元素空間
void releasemat(matrix & m)//釋放矩陣元素的空間
三、程式執行圖
1. 矩陣的建立(三種形式
2. 矩陣的轉置
3. 矩陣的複製
4. 矩陣的加法
5. 矩陣的減法
6. 矩陣的乘數
中國地質大學電路綜合實習報告
電路綜合實習報告 姓名 學號 班級 組別 指導老師 中國地質大學 武漢 技能要求1 一 函式發生器設計2 1 實習內容及要求2 2 設計方案2 3 除錯過程與結果10 4 測試資料記錄11 二 多功能數字鐘設計12 1 實習內容及要求12 2 設計方案13 3 除錯過程與結果21 三 自動量程轉換電...
中國地質大學 北京 參觀實習報告
中國地質大學博物館 參觀實習報告 指導教師 姓名班級 學號 北方工業大學建築工程學院工程地質 2011年4月 這次參觀實習主要參觀了地球科學展廳 恐龍廳 地球與生命歷史廳和地球物質廳,其中地球科學展廳和恐龍廳在參觀同時還聽講了博士生講解員的詳細講解,對地球以及恐龍的相關知識有了簡單的系統了解,從中獲...
中國地質大學環境監測實習報告
環境監測實習 鵝湖水質監測報告 指導老師 鮑建國李立青李民敬崔豔萍 姓名 實習時間 2012.1.3 2012.1.7 地點 取樣點 中國地質大學 武漢 北校區鵝湖 實驗地點 水工樓實驗室 目錄1 監測目的及取樣簡介2 2 測定方法與原理3 1.總氮測定方法與原理 2.總磷測定方法與原理 測定方法與...