I wanna list all arrangement, the following is my sample code:
const unsigned char item1[] = {'b'};
const unsigned char item2[] = { 'A', 'C' ,'D'};
const unsigned char item3[] = {'1','2'};
int _tmain(int argc, _TCHAR* argv[])
{
for (int i = 0; i < sizeof(item1) / sizeof(unsigned char); i++){
for (int j = 0; j < sizeof(item2) / sizeof(unsigned char); j++){
for (int k = 0; k < sizeof(item3) / sizeof(unsigned char); k++){
printf("%c%c%c\n",item1[i],item2[j],item3[k]);
}
}
}
return 0;
}
This will print all arrangement, but I am worried about if the array item is from item1
to item99
, the code is difficult to maintain. Is there a better solution to print all arrangement? Thanks!