every blog every motto: You will never know unless you try
0. 前言
简单记录,C++中获取二维数组行和列
1. 正文
#include<iostream>
using namespace std;
void test666()
{
cout << "我是测试程序:" << endl;
int arr[3][5] = {
{
1,0,1,0,1 },
{
1,1,1,0,1 },
{
0,0,0,0,1 }
};
int all = sizeof(arr)/sizeof(int);
cout << "数组元素总数为:"<<all << endl;
int column = sizeof(arr[0]) / sizeof(arr[0][0]);
int row = all / column;
cout << "数组的行:" << row << endl;
cout << "数组的列:" << column << endl;
}