I'm having some trouble with an assignment of mine. I have a string array with 30 words. I have to combine three of those words to form a password combinations. Combinations such as "airairair" or "allallall" are acceptable. I know that I should have 27000 combinations(30 * 30 * 30), but so far I'm only getting 900. Can somebody help me with this? What am I doing wrong? Code below:
#include<iostream>
#include<string>
#include<list>
#include<fstream>
using namespace std;
int main(int argc, char **argv[])
{
string passwords[] = { "air", "few", "all", "one", "cot", "jam", "sip", "gag", "arc", "egg",
"had", "hut", "tan", "paw", "pay", "got", "get", "pea", "rig", "cop",
"sat", "two", "who", "six", "sow", "dam", "tip", "lit", "awl", "dew" };
static int numWords = 0;
static int count = 0;
int arrLength = sizeof(passwords) / sizeof(passwords[0]);
ofstream f("passwords.dat"); //write passwords to file
int i, j, k;
for (i = 0; i < arrLength; i++)
{
for ( j = 0; i < arrLength; i++)
{
for ( k = 0 ; k < arrLength; k++)
{
cout << passwords[i] << passwords[j] << passwords[k];
f << passwords[i] << passwords[j] << passwords[k] << "\n";
}
}
}
f.close();
system("pause");
return 0;
}