ImageVerifierCode 换一换
格式:DOCX , 页数:16 ,大小:16.56KB ,
资源ID:27861058      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/27861058.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(字典的C++实现.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

字典的C++实现.docx

1、字典的C+实现#include #include using namespace std;#define MaxCharNum 256#define MaxPassLen 64#define MaxFileNameLen 32#define MaxFileNum 16/一些全局变量struct Flags bool Numbers; bool SmallLetters; bool CapitalLetters; bool SpecialCharacters;Flags flags=false,false,false,false; /使用全局标志来简化程序实现bool UserDefined;c

2、har charsMaxCharNum; /全局数组char passMaxPassLen;void Guide(); /提供选择,并设置相应标志void Build(); /生成字典void GetPass(int strlen,int passlen,int now,ofstream& fout); /递归函数,生成定长密码void Advanced(); /提供高级功能的选择菜单void AddPrefix(); /添加前缀void AddSuffix(); /添加后缀void Join(); /合并字典void Filter(); /过滤重复密码void ByeBye(); /退出程序

3、运行void main() coutendl Welcome to 7dic V1.0endl Code by chris7endl Fineshed at 2005-8-21endl E-mail: emailtechnevol/emailendl Blog: endl;Label: char choice; coutendl Please select one of the follows: endl 1. Make a dictionaryendl 2. Advanced toolsendl 3. Exitendlendl choice; switch(choice) case 1: G

4、uide(); Build(); break; case 2: Advanced(); break; case 3: ByeBye(); default: coutBad Input! Try again: ; while(choice3); coutendl Please select one of the follows: endl 1. Back to the top menuendl 2. Terminate meendlendl choice; switch(choice) case 1: goto Label; break; case 2: ByeBye(); default: c

5、outBad Input! Try again: ; while(choice2);void Guide() coutendl Please select one model: endl 1. Guide Modelendl 2. User-defined Modelendl 3. Exitendlendl choice; switch(choice) case 1: coutendl Please select characters needed: endl 1. All Numbers(0 to 9)endl 2. All Small Letters(a to z)endl 3. All

6、Capital Letters(A to Z)endl 4. All Printed Special Charactersendlendl Please enter some of the numbers above: ; getchar(); char numsMaxCharNum; int i; bool err; do gets(nums); err=false; for(i=0;istrlen(nums);i+) if(err=true) break; switch(numsi) case 1: flags.Numbers=true;break; case 2: flags.Small

7、Letters=true;break; case 3: flags.CapitalLetters=true;break; case 4: flags.SpecialCharacters=true;break; case : break; default: coutBad Input! Try again: ; err=true; while(err); break; case 2: UserDefined=true; coutendl Please enter all the characters that you select(less than MaxCharNum): endl; get

8、char(); gets(chars); break; case 3: ByeBye(); default: coutBad Input! Try again: ; while(choice3);void Build() int maxpasslen; coutendl maxpasslen; int len; char tmp; if(UserDefined=true) len=strlen(chars); for(int i=1;ilen;i+) for(int j=0;ji;j+) if(charsi=charsj) charsi=charslen-1; charslen-1=0; le

9、n-; i-; else len=0; if(flags.Numbers=true) for(tmp=0;tmp=9;tmp+) charslen+=tmp; if(flags.SmallLetters=true) for(tmp=a;tmp=z;tmp+) charslen+=tmp; if(flags.CapitalLetters=true) for(tmp=A;tmp=Z;tmp+) charslen+=tmp; if(flags.SpecialCharacters=true) for(tmp= ;tmp0;tmp+) charslen+=tmp; for(tmp=:;tmpA;tmp+

10、) charslen+=tmp; for(tmp=;tmpa;tmp+) charslen+=tmp; for(tmp=;tmp=;tmp+) charslen+=tmp; charslen=0; ofstream fout(7.dic); if(!fout) cerrendlCannot open output file!endl; ByeBye(); int now=0; for(int i=1;i=maxpasslen;i+) GetPass(len,i,now,fout); fout.close(); coutendlThe dictionary needed has been bul

11、it successfully.endl;void GetPass(int strlen,int passlen,int now,ofstream& fout) if(now=passlen) for(int i=0;inow;i+) foutpassi; foutendl; return; for(int j=0;jstrlen;j+) passnow=charsj; GetPass(strlen,passlen,now+1,fout); void Advanced() coutendl Please select one of the follows: endl 1. Add prefix

12、 to each password in the dictionaryendl 2. Add suffix to each password in the dictionaryendl 3. Join dictionaries togetherendl 4. Filter a specified dictionaryendl 5. Exitendlendl choice; switch(choice) case 1: AddPrefix(); break; case 2: AddSuffix(); break; case 3: Join(); break; case 4: Filter();

13、case 5: ByeBye(); default: coutBad Input! Try again: ; while(choice3);void AddPrefix() coutendl Make sure the dictionary to be added prefix is in current directory.endl dicname; ifstream fin(dicname); if(!fin) cerrendlCan not open input file.endl; ByeBye(); coutendlPlease enter the prefix needed: ;

14、char prefixMaxPassLen; getchar(); gets(prefix); ofstream fout(PreAdded.dic); if(!fout) cerrendlCan not open output file.endl; ByeBye(); char bufferMaxPassLen,PreAddedMaxPassLen; strcpy(PreAdded,prefix); while(!fin.eof()&fin.good() fin.getline(buffer,sizeof(buffer); if(strlen(buffer)!=0) strcat(PreAd

15、ded,buffer); foutPreAddedendl; strcpy(PreAdded,prefix); fin.close(); fout.close(); coutendlPrefix has been added to the specified dictionary successfully.endl;void AddSuffix() coutendl Make sure the dictionary to be added suffix is in current directory.endl dicname; ifstream fin(dicname); if(!fin) c

16、errendlCan not open input file.endl; ByeBye(); coutendlPlease enter the suffix needed: ; char suffixMaxPassLen; getchar(); gets(suffix); ofstream fout(SufAdded.dic); if(!fout) cerrendlCan not open output file.endl; ByeBye(); char bufferMaxPassLen; while(!fin.eof()&fin.good() fin.getline(buffer,sizeo

17、f(buffer); if(strlen(buffer)!=0) strcat(buffer,suffix); foutbufferendl; fin.close(); fout.close(); coutendlSuffix has been added to the specified dictionary successfully.endl;void Join() coutendl Make sure the dictionaries to be joined are in current directory.endl Please enter names of dictionaries

18、: ; char cmdlineMaxFileNameLen*MaxFileNum; getchar(); gets(cmdline); char filesMaxFileNameLenMaxFileNum; int len=strlen(cmdline); int name=0; int tmp; for(int i=0;ilen;i+) tmp=0; while(cmdlinei!= &cmdlinei!=t&ilen) filesnametmp+=cmdlinei+; if(cmdlinei= |cmdlinei=t) filesnametmp=0; while(cmdlinei+1=

19、|cmdlinei+1=t) i+; name+; filesnametmp=0; ofstream fout(Joined.dic); char bufferMaxPassLen; for(int j=0;j=name;j+) ifstream fin(filesj); if(!fin) cerrendl Error opening input file: filesj.endl; ByeBye(); while(!fin.eof()&fin.good() fin.getline(buffer,sizeof(buffer); foutbufferendl; fin.close(); fout

20、.close(); coutendlThe specified dictionaries have been joined successfully.endl;void Filter() coutendl Make sure the dictionary to be filtered is in current directory.endl dicname; ifstream fin(dicname); if(!fin) cerrendlCan not open input file.endl; ByeBye(); ofstream fout(Filtered.dic); if(!fout)

21、cerrendlCan not open output file.endl; ByeBye(); char bufferMaxPassLen; char tmpMaxPassLen; bool isin; while(!fin.eof()&fin.good() fin.getline(buffer,sizeof(buffer); ifstream fcmp(Filtered.dic); if(!fcmp) cerrendlCan not open output file.endl; ByeBye(); isin=false; while(!fcmp.eof()&fcmp.good() fcmp

22、.getline(tmp,sizeof(tmp); if(!strcmp(tmp,buffer) isin=true; break; if(!isin) foutbufferendl; fcmp.close(); fin.close(); fout.close(); coutendlThe specified dictionary has been filtered successfully.endl;void ByeBye() coutendl Thanks for using this program.endl If any bug is found, please contact me.endl Press enter to exit.; getchar(); getchar(); exit(0);

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1