⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 caesarencryt.cpp

📁 Caesar加密算法
💻 CPP
字号:
#include<iostream>#include<fstream>#include<string>#include<cctype>using namespace std;void OpenForOutput(ofstream& outPut,string filename);void OpenForInput(ifstream& inPut,string filename);int main(){ ofstream outFile; ifstream inFile; int i; string infileName,outfileName; cout<<"Input file name:"; cin>>infileName; cout<<"Input the number the Caesar parameter:"<<endl; cin>>i; cout<<"Output file name:"; cin>>outfileName; char ch; char temp; OpenForInput(inFile,infileName); OpenForOutput(outFile,outfileName);      while(inFile.get(ch))        {        cout<<ch;        ch=tolower(ch);        temp='z'-i;        if(ch>temp&&ch<='z')            ch=ch-26+i;        else if(ch>='a'&&ch<=temp)                ch=ch+i;        outFile<<ch;        } inFile.close(); outFile.close(); return 0;}void OpenForOutput(ofstream& outPut,string filename){ outPut.open(filename.c_str(),ios::app); if(!outPut)   cout<<"Can\'t open "<<filename<<endl;}void OpenForInput(ifstream& inPut,string filename){ inPut.open(filename.c_str()); if(!inPut)   cout<<"Can\'t open "<<filename<<endl;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -