C++ 数组 一维数组 二维数组

时间:2015-06-29 05:25:39
【文件属性】:
文件名称:C++ 数组 一维数组 二维数组
文件大小:235KB
文件格式:PPT
更新时间:2015-06-29 05:25:39
C++ 数组 数组定义及实例 用二维数组实现二维矩阵的加法和乘法 #include #define SIZE 4 void addMatrix(int [ ][SIZE], int [ ][SIZE], int [ ][SIZE]); void mulMatrix(int [ ][SIZE], int [ ][SIZE], int [ ][SIZE]); void diaplayMatrix( int [ ][SIZE]); int main() { int m1[ SIZE ][ SIZE ] = {{1, 1, 1, 1},{2, 2, 2, 2}, {3, 3, 3, 3},{4, 4, 4, 4} }; int m2[ SIZE ][ SIZE ] = {{5, 5, 5, 5},{6, 6, 6, 6}, {7, 7, 7, 7},{8, 8, 8, 8}}; int resultAdd[ SIZE ][ SIZE ] = { 0 }; int resultMul[ SIZE ][ SIZE ] = { 0 }; diaplayMatrix(m1); cout << " +" << endl; diaplayMatrix(m2); addMatrix(m1, m2, resultAdd); cout << " =" << endl;

网友评论

  • 还不错 但是没有解决我的疑问