大神 帮帮忙啊 我要利用凯撒密码 并先打开一个文件夹 把文件夹内的东西解密
大神 救命啊!!!!文件名叫做encrypted。txt内容是Rqfh pruh lqwr wkh euhdfk,ghdu iuihqgv,rqfh pruh;
Ru forvh wkh zdoo xs zlwk rxu Hqjolvk ghdg,
Lq shdfh wkhuh'v qrwklqj vr ehfrphv d pdq
Dv prghvw vwlooqhvv dqg kxplolwb;
Exw zkhq wkh eodvw ri zdu eorzv lq rxu hduv,
Wkhq lplwdwh wkh dfwlrq ri wkh wljhu;
vwliihq wkh vlqhzv,vxpprq xs wkh eorrg,
用C++编程:
#include<fstream>
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
char ch;
ifstream ifile("g:\\encrypted.txt");
cout<<"读入encrypted.txt"<<endl;
do{
ch=ifile.get();
if((ch>='D'&&ch<='Z')||(ch>='d'&&ch<='z')) ch-=3;
else
{
if(ch=='A') ch='X';
if(ch=='B') ch='Y';
if(ch=='C') ch='Z';
if(ch=='a') ch='x';
if(ch=='b') ch='y';
if(ch=='c') ch='z';
}
cout<<ch;
}while(ch!=EOF); //读到文本结束符为止
cout<<endl;
ifile.close();
return 0;
}
本回答被提问者采纳密匙是3
追答详细过程见2楼,lz给分ta吧!