【发布时间】:2013-08-26 09:20:03
【问题描述】:
我想得到两个int 元素的所有组合,比如 j 和 i,两者都不应该小于 3,这是我尝试过的:
for (int i = 10; i>=3;i--)
{
for (int j = 23, j >= 3,j--)
{
std::cout << " the i value " << i
<< "the j value :" << j << std::endl; // since I'm using those combinations
// for the rest of my code I wrote
// this to keep things simple
}
}
他们在没有for循环的情况下无论如何都要这样做吗?
【问题讨论】:
-
您要在这里优化什么?
-
由于这不是您的真实代码,并且您没有描述您的真实应用程序,我们如何帮助优化您的代码?
-
是什么让你觉得这还不够快?
-
不,引擎,我确定不是。需要时间的是您在循环中所做的任何事情。
-
cv::findChessboardCorners()-- 嗯,取 [3..10] 和 [3..23] 的叉积并不是找到棋盘角的好方法。也许如果您更准确地了解您真正想要实现的目标......事实上,这是一个经典的 XY 问题 (meta.stackexchange.com/questions/66377/what-is-the-xy-problem)。
标签: c++ algorithm optimization