C++高校基础教程_7_9多维数组
C++大学基础教程_7_9多维数组
//_7_9_main_1.cpp //声明初始化一个数组 #include <iostream> using namespace std; void printArray(const int [][3]);//声明二元数组的规则!!! int main() { int array1[2][3] = {{1,2,3},{4,5,6}}; int array2[2][3] = {1,2,3,4,5}; int array3[2][3] = {{1,2},{4}}; cout << "Values in array1 by row are:" << endl; printArray(array1); cout << "\nValues in array2 by row are:" << endl; printArray(array2); cout << "\nValues in array3 by row are:" << endl; printArray(array3); system("pause >> cout"); return 0; } void printArray(const int a[][3]) { for(int i=0;i<2;i++) { for(int j=0;j<3;j++) cout << a[i][j] << " "; cout << endl; } }