📄 解密算法.cpp
字号:
//学校:武汉理工大学
//qq号:297416605
//姓名:万艳良
#include<iostream.h>
void main()
{
char exit;
cout<<"Do you want to exit?(y or n)"<<endl;
cin>>exit;
while(exit!='y'||exit=='n')
{
char c[50],c1[60],b,p[50];
int i=0,j=0,c0=0,d=1,d1=0,N=0,m=1,n=1,q=0;
cout<<"please input the Key N:"<<endl;
cin>>N;
cout<<"Please input the C-text(ended with the letter @):"<<endl;
cin>>b;
c[i]=b;
i++;
while(b!='@')
{
cin>>b;
if(b=='@')
c[i]=' ';
else
c[i]=b;
i++;
}
i--;
if(i%N==0)
{
j=i/N;
for(c0=0;c0<i;c0++)
{
c1[c0]=c[c0];
}
}
else
{
j=i/N+1;
for(int x=(i%N+1)*j;x<=N*j;x+=j)
{
c1[x-1]='*';
}
for(int p1=0;p1<i;p1++)
{
if(c1[q]=='*')
q++;
c1[q]=c[p1];
q++;
}
}
for(d=1;d<=N;d++)
{
d1=d;
for(c0=m;c0<=n*j;c0++)
{
p[d1-1]=c1[c0-1];
d1+=N;
}
d1=0;
m+=j;n+=1;
}
d1=N;
for(c0=m;c0<=i;c0++)
{
p[d1-1]=c1[c0-1];
d1+=N;
}
//输出明文
cout<<"The P-text is:"<<endl;
for(c0=0;c0<i;c0++)
cout<<p[c0]<<"";
cout<<endl;
cout<<"Do you want to exit?(y or n)"<<endl;
cin>>exit;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -