void recurisionAccess(int factor[3][4], int lengths[3], int colum, int row)
{
int i = 0;
int j = 0;
int k = 0;
int len = 0;
int len_num = 0;
int totalLength = 1;
for (i=0; i<colum; i++)
{
totalLength *= lengths[i];
}
for (i=0; i<totalLength; i++)
{
k = i;
len_num = 0;
for (j=0; j<colum; j++)
{
len = lengths[len_num];
/* first do % with len, then do / with len, next time do it again on
new len */
printf("%d ", factor[j][k%len]);
k = k / len;
len_num++;
}
printf("\n");
}
}
int main()
{
recurisionAccess(factor, lengths, 3 ,4);
return 0;
}
循环次数从底到上为3 x 2 x 4 = 24
我们可以认为循环中 i 的值一个由3位混合进制的数,每一位使用不同的进制,进制自底向上