让我们使用广度优先搜索类型算法来做到这一点
starting from
Root:
have 10 children, i = 0,1,...,9
so , this root must have an iterator, 'i'
therefore this outermost loop will iterate 'i' from 0 to 9
i:
for each 'i', there are 5 children (ix , ixx, ixxx, ixxxx, ixxxxx)
( number of chars at the string )
so each i should have its own iterator 'j' representing number of chars
the loop inside Root's loop will iterate 'j' from 1 to 5
j:
'j' will have 'j' number of children ( 1 -> x , 2 -> xx ,..., 5-> xxxxx)
so each j will have its own iterator 'k' representing each "character"
so, 'k' will be iterated inside this j loop, from 1 to j
( i=2, j=4, k = 3 will focus on 'A' at string "2xxAx" )
k:
each 'k' represents a character, so it iterates from 'a' to 'z'
each k should have a iterator(value) 'c' that iterates from 'a' to 'z' (or 97 to 122)
我认为这比我之前想给你看的更有意义。:) 如果你不明白,请告诉我.. 顺便说一句,这是一个有趣的问题 :)