I need to generate the letters in this way:
1) a
2) b
3) c
4) d
5) e
.
.
.
26) z
27) ab
28) ac
29) ad
.
.
.
51) az
52) bc
53) bd
54) be
.
(and this goes all the way down to...)
.
.
83681) vwxyz
So basically how I've done it so far is put all the letters from a-z into a set (the alphabet so to speak) and then I'm iterating over that alphabet, but I'm really stumped on the algorithm to generate the letters in this pattern. Another problem I had is if I do something like this for example:
Iterator it = alphabet.iterator(); Iterator it2 = it; it2.next();
If I do this it seems that my it2.next() will increment not only "it2", but "it" as well. I assume this is because with iterators if you use the assignment operator= it assigns the actual address to that iterator. Is there any way around this so I could assign iterator it2 with the position of iterator it, but be able to increment them seperately? I think if I could do that it would allow me to figure out this algorithm much easier.
Maybe I am taking a completely wrong approach to this, anyways I'm sure the geniuses here will have some good ideas :-). Any help greatly appreciated.
This post has been edited by Perogy: 13 November 2009 - 03:55 PM

New Topic/Question
Reply




MultiQuote










|