I am trying to make a brute-force algorithm in C++, to solve problems. I have previously made a brute-force algorithm in Python but this used a 3rd party library, which means I can't convert it to C++. I quite like this design, that I have found;
#include <iostream>
using namespace std;
int main() {
string characters = "abcde";
int length = 5;
string word = "";
for(int i = word.length(); i <= length; i++) {
for(int l = 0; l < characters.length(); l++) {
word += characters[l];
cout << word << "\n";
}
}
return 0;
}
, but due to some bug(s), its output is:
abcdeabcde
abcdeabcdea
abcdeabcdeab
abcdeabcdeabc
abcdeabcdeabcd
abcdeabcdeabcde
and so on... The result, that I need is:
a
b
c
d
e
aa
ab
ac
ad
ae
ba
bb
bc
...
Thanks In Advance :)
Any help is appreciated :)