C/C++:移位密码穷举解密

来源:互联网 发布:sftp windows 编辑:程序博客网 时间:2024/05/22 00:33
#include<iostream>using namespace std;#define N 1000void decrypt(char x[N]){for(int i=1;i<=25;++i){for(int j=0;;++j){       if(x[j]>96&&x[j]<123)             x[j]=(x[j]-1-122)%26+122;            else if(x[j]>64&&x[j]<91)       x[j]=(x[j]-1-90)%26+90;            else   x[j]=x[j];if(x[j]==0) break;}cout<<"The result is:"<<x<<endl;}}int main(){char x[N] = {0};cout<<"Please enter the message:";cin.getline(x,N);    decrypt(x);return 0;}

0 0
原创粉丝点击