欢迎来到天天文库
浏览记录
ID:50640567
大小:36.50 KB
页数:7页
时间:2020-03-07
《凯撒密码程序.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;i5、-'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
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
此文档下载收益归作者所有