aa.cpp
来自「密码学的简单加密」· C++ 代码 · 共 43 行
CPP
43 行
#include<iostream.h>
#include<iomanip.h>
#include<fstream.h>
void main(){
int n;//移位数
char w;
cout<<"移位数:";
cin>>n;
int op;
cout<<"加密输入1,解密输入0,文件名为ft.txt:";
cin>>op;
cout<<endl;
ifstream fin("ft.txt");//加密信息用大写,如需空格,请用0代替,结束用#号表示
switch(op)
{
case 1:
for (;;)
{
fin>>w;
if(w=='#') break;
if(w=='0') cout<<' ';
else{
if(w+n>90) cout<<char(w+n-26);
else
cout<<char(w+n);}
}
cout<<endl;
case 0:
for (;;)
{
fin>>w;
if(w=='#') break;
if(w=='0') cout<<' ';
else{
if(w-n<65) cout<<char(w-n+26);
else
cout<<char(w-n);}
}
cout<<endl;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?