📄 createpass2.cpp
字号:
// CreatePass2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "CreatePass2.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
long nminl=1,nmaxl=3;
void CreatePass()
{
#define passwordmax 8
char a[]="0123456789abcdefghijklmnopqrstuvwxyz";
long ndictcount=sizeof(a);
char cpass[passwordmax+2];
long array[passwordmax];
ASSERT(nminl<=nmaxl&&nmaxl<=passwordmax);
long nlenghth=nminl;
register long j,i=0;
bool bnext;
CStdioFile file;
file.Open("E:\\CreatePass2\\dict.txt",CFile::modeCreate|CFile::modeWrite);//
while(nlenghth<=nmaxl)
{
for(i=0;i<passwordmax;i++)
array[i]=0;
bnext=true;
while(bnext)
{
for(i=0;i<nlenghth;i++)
cpass[i]=a[array[i]];
cpass[i]='\0';
file.WriteString(cpass);
file.WriteString("\n");
for(j=nlenghth-1;j>=0;j--)
{
array[j]++;
if(array[j]!=ndictcount-1) break;
else
{
array[j]=0;
if(j==0) bnext=false;
}
}
}
nlenghth++;
}
file.Close();
}
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
CString strHello;
strHello="请输入生成密码的位数:\n";
cout<<(LPCTSTR)strHello<<endl;
cin>>nmaxl;
strHello.LoadString(IDS_HELLO);
CreatePass();
cout << (LPCTSTR)strHello << endl;
}
return nRetCode;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -