I\'m trying to create an algorithm in C# which produces the following output strings:
AAAA
AAAB
AAAC
...and so on...
ZZZX
ZZZY
ZZZZ
What is the
A very simple but awesome code that generates all words of 3 and 4 letters of english language
#include
using namespace std;
char alpha[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
int main() {
int num;
cin >> num;
if (num == 3) { //all 3 letter words
for (int i = 0; i <= 25; i++) {
for (int o = 0; o <= 25; o++) {
for (int p = 0; p <= 25; p++) {
cout << alpha[i] << alpha[o] << alpha[p] << " ";
}
}
}
}
else if (num == 4) { //all 4 letter words
for (int i = 0; i <= 25; i++) {
for (int o = 0; o <= 25; o++) {
for (int p = 0; p <= 25; p++) {
for (int q = 0; q <= 25; q++) {
cout << alpha[i] << alpha[o] << alpha[p] << alpha[q] << " ";
}
}
}
}
}
else {
cout << "Not more than 4"; //it will take more than 2 hours for generating all 5 letter words
}
}