密码破解程序组合程序

Password Cracker Combination Program

本文关键字:程序 组合 密码破解      更新时间:2023-10-16

我在分配作业时遇到了一些麻烦。我有一个包含 30 个单词的字符串数组。我必须组合其中三个词来形成密码组合。"airairair"或"allallall"等组合是可以接受的。我知道我应该有 27000 种组合(30 * 30 * 30),但到目前为止我只得到了 900 种。有人可以帮助我吗?我做错了什么?代码如下:

#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;
}

你的J循环是错误的。应该是for( j=0 ; j < arrLength; j++).

但是,它被错误地键入为 for( j=0 ; i < arrLength ; i++ )

因此,它将只提供

30*30 组合而不是 30*30*30