A
a
After several days struggling, I'm still unable to generate a string
automatically *ONE by ONE*. I don't want to create a long array memorizing
all the output strings and then traverse this array to print the content
out.
For example, for studying the frequency of 5-letter words composed of
{a,b,c,d,e} in a
string, the length of array of (aaaaa, aaaab,
...., caaaa, ..., eeeee) will then be 5*5*5*5*5.
Indeed what I want is to print aaaaa first, then aaaab, then aaaac, ...,
eeeea, eeeeb, ..., eeeee.
The problem is complicated by that I want to study n-letter words (the above
example, n=5).
So I try write something like:
char lookup(int lv, int idx) {
if (lv != 0)
lookup(lv-1, idx);
if (idx != 0)
lookup(lv, idx-1);
if (idx == 0) return 'a';
else if (idx == 1) return 'b';
else if (idx == 2) return 'c';
else if (idx == 3) return 'd';
else if (idx == 4) return 'e';
}
but indeed in this way I need to create the long array concatenating one by
one....
Please help I'm not asking for the whole codes but I really don't know
what direction I should go for to complete the seemingly automatic task.
automatically *ONE by ONE*. I don't want to create a long array memorizing
all the output strings and then traverse this array to print the content
out.
For example, for studying the frequency of 5-letter words composed of
{a,b,c,d,e} in a
string, the length of array of (aaaaa, aaaab,
...., caaaa, ..., eeeee) will then be 5*5*5*5*5.
Indeed what I want is to print aaaaa first, then aaaab, then aaaac, ...,
eeeea, eeeeb, ..., eeeee.
The problem is complicated by that I want to study n-letter words (the above
example, n=5).
So I try write something like:
char lookup(int lv, int idx) {
if (lv != 0)
lookup(lv-1, idx);
if (idx != 0)
lookup(lv, idx-1);
if (idx == 0) return 'a';
else if (idx == 1) return 'b';
else if (idx == 2) return 'c';
else if (idx == 3) return 'd';
else if (idx == 4) return 'e';
}
but indeed in this way I need to create the long array concatenating one by
one....
Please help I'm not asking for the whole codes but I really don't know
what direction I should go for to complete the seemingly automatic task.