问题:将0~360中任意一个数n,放入72个数组(每个数组的数组成员都为5个不同的数)中的一个。
我们可以先定义一个数组m[72],里面72个变量分别对应72个数组名,我们用n/5得到n对应的m数组中存储的数组名即m[n/5].
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef int(*M)[int];
M m[72]={.......................};
//调用72个数组
m[n/5][i] = n;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// the versions to be tested
typedef void(*FunctionPointer)(cv::Mat, int);
FunctionPointer functions[NTESTS] = { colorReduce, colorReduce1, colorReduce2, colorReduce3, colorReduce4,
colorReduce5, colorReduce6, colorReduce7, colorReduce8, colorReduce9,
colorReduce10, colorReduce11, colorReduce12, colorReduce13, colorReduce14};
// repeat the tests several times
int n = NITERATIONS;
for (int k = 0; k<n; k++) {
std::cout << k << " of " << n << std::endl;
// test each version
for (int c = 0; c < NTESTS; c++) {
images[c] = cv::imread("boldt.jpg");
// set timer and call function
tinit = cv::getTickCount();
functions[c](images[c], 64);
t[c] += cv::getTickCount() - tinit;
std::cout << ".";
}
std::cout << std::endl;
}