《凯撒密码程序.doc》由会员分享,可在线阅读,更多相关《凯撒密码程序.doc(7页珍藏版)》请在三一文库上搜索。
1、#include#include char JFjiami(char ch,int n)while(ch=A&ch=a&ch=0&ch=A&ch=a&ch=0&ch=A&ch=a&ch=0&ch=A&ch=Z) for(i=0;i=0&h=a&ch=z) for(i=0;i=0&h=0&ch=9) for(i=0;i=0&h=9) return (0+h); return ch;void menu()printf(n=);printf(n 1.JFjiami the file);printf(n 2.CFljiami the file);printf(n 3.JFjiemi the file)
2、;printf(n 4.CFjiemi the file);printf(n 5.Quitn);printf(=n);printf(Please input a number rang from 1 to 5 and select a item:);return;void main()int i,n;char ch0,ch1;FILE *in,*out;char infile20,outfile20;sleep(3);menu();ch0=getch();while(ch0!=5) if(ch0=1) clrscr(); printf(nPlease input the infile:); s
3、canf(%s,infile); if(in=fopen(infile,r)=NULL) printf(Can not open the infile!n); printf(Press any key to exit!n); getch(); exit(0); printf(Please input the key:); scanf(%d,&n); printf(Please input the outfile:); scanf(%s,outfile); if(out=fopen(outfile,w)=NULL) printf(Can not open the outfile!n); prin
4、tf(Press any key to exit!n); fclose(in); getch(); exit(0); while(!feof(in) fputc(JFjiami(fgetc(in),n),out); printf(nJFjiami is over!n); fclose(in); fclose(out); sleep(1); if(ch0=2) clrscr(); printf(nPlease input the infile:); scanf(%s,infile); if(in=fopen(infile,r)=NULL) printf(Can not open the infi
5、le!n); printf(Press any key to exit!n); getch(); exit(0); printf(Please input the key:); scanf(%d,&n); printf(Please input the outfile:); scanf(%s,outfile); if(out=fopen(outfile,w)=NULL) printf(Can not open the outfile!n); printf(Press any key to exit!n); fclose(in); getch(); exit(0); while(!feof(in
6、) fputc(CFjiami(fgetc(in),n),out); printf(nCFjiami is over!n); fclose(in); fclose(out); sleep(1); if(ch0=3) clrscr(); printf(nPlease input the infile:); scanf(%s,infile); if(in=fopen(infile,r)=NULL) printf(Can not open the infile!n); printf(Press any key to exit!n); getch(); exit(0); printf(Please i
7、nput the key:); scanf(%d,&n); printf(Please input the outfile:); scanf(%s,outfile); if(out=fopen(outfile,w)=NULL) printf(Can not open the outfile!n); printf(Press any key to exit!n); fclose(in); getch(); exit(0); while(!feof(in) fputc(JFjiemi(fgetc(in),n),out); printf(nJFjiemi is over!n); fclose(in)
8、; fclose(out); sleep(1); if(ch0=4) clrscr(); printf(nPlease input the infile:); scanf(%s,infile); if(in=fopen(infile,r)=NULL) printf(Can not open the infile!n); printf(Press any key to exit!n); getch(); exit(0); printf(Please input the key:); scanf(%d,&n); printf(Please input the outfile:); scanf(%s
9、,outfile); if(out=fopen(outfile,w)=NULL) printf(Can not open the outfile!n); printf(Press any key to exit!n); fclose(in); getch(); exit(0); while(!feof(in) fputc(CFjiemi(fgetc(in),n),out); printf(nCFjiemi is over!n); fclose(in); fclose(out); sleep(1); menu(); ch0=getch();clrscr(); printf(nGood Bye!n);sleep(3);