如何进行自动阵列检测?
how to do automatic array detection?
我有时会将这些数字与数组混淆并且无法计数,因为开头是从头开始而不是从头开始。 为了不让我感到困惑,我必须删除具有arr[4][4].
大小的数字
我想找到一种方法来自动工作,更准确地说,它会自动确定数字。
我真的很困惑 对我来说arr[4][4]
.应该是arr[3][3].
因为计数器从零开始0,1,2,3
int arr[][] // <--
{
{ 0,0,0,1 },
{ 1,0,0,0 },
{ 0,2,0,4 },
{ 1,1,0,1 }
};
您可能喜欢这样的辅助函数:
#include < array >
#include < iostream >
template < typename ... T >
constexpr auto f( T ... args)
{
return std::array< std::tuple_element_t<0, std::tuple<T...>>, sizeof...(args)> { args...};
}
int main()
{
constexpr auto arr =
f(
f( 0,0,0,1),
f( 1,0,0,0),
f( 0,2,0,4),
f( 1,1,0,1)
);
for ( auto& x: arr ) {
for ( auto y: x ) {
std::cout << y << " " ;
}
std::cout << std::endl;
}
// or access via []
std::cout << arr[0][3] << std::endl;
std::cout << arr[2][3] << std::endl;
}
相关文章:
- OpenMP阵列性能较差
- 使用CMake检测支持的C++标准
- 当套接字连接断开时检测C/C++Unix
- 如何将三维尺寸不固定的三维阵列展平为一维阵列
- C/C++预处理器是否可以检测一些编译器选项
- 当我的阵列太大时出现分段错误
- WMI检测进程创建事件-c++
- 基于树莓pi的tensorflow lite量化ssd目标检测
- 下面是我为检测链接列表中的循环而制作的代码
- 如何进行自动阵列检测?
- 一维阵列的运动检测(神经网络或其他选项?
- 保护类内存阵列以检测分段错误
- 检测到堆损坏(动态阵列重新调整大小)
- 如何检测变量是否是犰狳阵列
- 将检测到的人脸与现有人脸阵列与 android 中的 opencv 进行比较
- 由于阵列使用,检测到堆损坏
- 检测2D阵列的列中的重复
- 从Blob检测中提取OpenCV轮廓阵列
- 使用 OpenCV 实时检测 LED 阵列的每个 LED
- 阵列超出范围检测