资源描述:
《n=4排列码源程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、n=4的排列码源程序#include#include#include#include#include#includecharSLIST[256][24],fuhao[4];inta[4],b[4],Hj,row,percent;charA[8],B[8],flagbit[4],Anum,Ahnum,Alnum,Bnum,Bhnum,Blnum;intpw0[3];FILE*outdata,*fplog;lo
2、ngintcomplete,flen,timeswitch;chartemp1,temp2,temp3,index1,index2,index3;charTemp[4][3],Index[4][3];charch='b';//加密函数voidencrypt(char*in_filename,char*out_filename,char*pwd,intN);//解密函数voidriddle(char*in_filename,char*out_filename,char*pwd,intN);//主函数main(in
3、targc,char*argv[]){FILE*fp1;charin_filename[30];charout_filename[30];charstrl,pwd[30];charTimes,te;//times加密次数booltu;//判断条件chartemp;//输入原文件并检测是否能打开do{printf("请输入所要加密/解密的文件所在的路径和名称:");scanf("%s",in_filename);fp1=fopen(in_filename,"rb");//打开所要加密的文件检测if(fp1
4、==NULL){printf("无法打开文件!!");}}while(!fp1);//关闭文件fclose(fp1);//输入原文件并检测是否能打开//----------------------------------------------------------------------------//选择加密还是解密并检测printf("请输入'e'进行加密,'r'进行解密:");agin1:tu=false;te=(char)_getch();if(isupper(te))te+=32;if
5、(te=='e'
6、
7、te=='r')tu=true;if(!tu)gotoagin1;//如果输入不是e或r则重新输入_putch(te);//若是e或r则将字符显示在终端.agin1e:temp=(char)_getch();if(temp!=13)if(temp=='b'){_putch('b');_putch('');_putch('b');gotoagin1;}elsegotoagin1e;ch=te;//将输入的加密/解密类型赋给ch;_putch('');//选择加密还是解密并检测//--
8、-----------------------------------------------------------------------------//输入目标文件并检测是否存在agin5:printf("请输入加密/解密后要输出的文件路径和名称:");scanf("%s",out_filename);//检测文件是否存在if(!access(out_filename,4)){printf("该文件以存在!是否覆盖?(N
9、Y)");agin4:tu=false;te=(char)_getch();
10、if(isupper(te))//若输入的是大写字母则变为小写字母te+=32;if(te=='n'
11、
12、te=='y')tu=true;if(!tu)gotoagin4;_putch(te);agin4e:temp=(char)_getch();if(temp!=13)if(temp=='b'){_putch('b');_putch('');_putch('b');gotoagin4;}elsegotoagin4e;_putch('');if(te!='y')gotoagin5;elsegotoend
13、;}end://输入加密的次数并检测printf("请输入加密的次数(1-4)");agin2:tu=false;te=(char)_getch();if(isdigit(te))if(te>'0'&&te<'5')tu=true;if(!tu)gotoagin2;_putch(te);//显示出输入的加密次数agin2e:temp=(char)_getch();if(temp!=