用C++实现凯撒密码,在不知道密钥的情况下,循环25次
#include<iostream>
#include<string.h>
#include<string>
using namespace std;
int main()
{
char str[108] = "UIF RVJDL CSPXO GPY KVNQT PWFS UIF MBAZ EPH PG DBFTBS BOE ZPVS VOJRVF TPMVUJPO JT NFSMFPDMSGNB";
int n = strlen(str);
cout<<n<<endl;
for (int i=1; i<26; i++)
{
for(int j=0; j<n; j++ )
if(str[j]>='A'&&str[j]<='Z')
{
str[j]=char((str[j]-'A'+1)%26+'A');
}
cout<<str<<endl;
}
}
5699

被折叠的 条评论
为什么被折叠?



