凯撒密码程序.doc

凯撒密码程序.doc

ID:50640567

大小:36.50 KB

页数:7页

时间:2020-03-07

凯撒密码程序.doc_第1页
凯撒密码程序.doc_第2页
凯撒密码程序.doc_第3页
凯撒密码程序.doc_第4页
凯撒密码程序.doc_第5页
资源描述:

《凯撒密码程序.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、#include#includecharJFjiami(charch,intn){while(ch>='A'&&ch<='Z'){n=n%26;return('A'+(ch-'A'+n)%26);}while(ch>='a'&&ch<='z'){n=n%26;return('a'+(ch-'a'+n)%26);}while(ch>='0'&&ch<='9'){n=n%10;return('0'+(ch-'0'+n)%10);}returnch;}charJFjiemi(charch,intn){staticintk

2、;while(ch>='A'&&ch<='Z'){k=n%26;n=26-k;return('A'+(ch-'A'+n)%26);}while(ch>='a'&&ch<='z'){k=n%26;n=26-k;return('a'+(ch-'a'+n)%26);}while(ch>='0'&&ch<='9'){k=n%10;n=10-k;return('0'+(ch-'0'+n)%10);}returnch;}charCFjiami(charch,intn){if(n%2==0)n=n%10+1;elsen=n%10;if(n%5==0)n=n+2;e

3、lsen=n;while(ch>='A'&&ch<='Z'){return('A'+((ch-'A')*n)%26);}while(ch>='a'&&ch<='z'){return('a'+((ch-'a')*n)%26);}while(ch>='0'&&ch<='9'){return('0'+((ch-'0')*n)%10);}returnch;}charCFjiemi(charch,intn){inti;intk,h;if(n%2==0)n=n%10+1;elsen=n%10;if(n%5==0)n=n+2;elsen=n;while(ch>='

4、A'&&ch<='Z'){for(i=0;i<100;i++){k=((ch-'A')+i*26)%n;if(k==0)h=((ch-'A')+i*26)/n;if(h>=0&&h<=26)return('A'+h);}}while(ch>='a'&&ch<='z'){for(i=0;i=0&&h<=26)return('a'+h);}}while(ch>='0'&&ch<='9'){for(i=0;i

5、-'0')+i*10)%n;if(k==0)h=((ch-'0')+i*10)/n;if(h>=0&&h<=9)return('0'+h);}}returnch;}voidmenu(){printf("=========================================================");printf("1.JFjiamithefile");printf("2.CFljiamithefile");printf("3.JFjiemithefile");printf("4.CFjiemithefile"

6、);printf("5.Quit");printf("=========================================================");printf("Pleaseinputanumberrangfrom1to5andselectaitem:");return;}voidmain(){inti,n;charch0,ch1;FILE*in,*out;charinfile[20],outfile[20];sleep(3);menu();ch0=getch();while(ch0!='5'){if(ch0=

7、='1'){clrscr();printf("Pleaseinputtheinfile:");scanf("%s",infile);if((in=fopen(infile,"r"))==NULL){printf("Cannotopentheinfile!");printf("Pressanykeytoexit!");getch();exit(0);}printf("Pleaseinputthekey:");scanf("%d",&n);printf("Pleaseinputtheoutfile:");scanf("%s",outfile)

8、;if((out=fopen(outfile,"w"))==NULL){printf("Cannotopen

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。