一个简单的恺撒加密程序

类别:编程语言 点击:0 评论:0 推荐:

 

#include<iostream>
#include<fstream>
void main(void)

 char strch,ch;
   int i,x;
 ifstream readfile;
 ofstream writefile; 
 readfile.open("1.txt",ios::in | ios::nocreate);  
if(!readfile)  

cerr<<"cannot open thie file for input"<<endl;        
exit(0);    }  
 writefile.open("2.txt",ios::in | ios::nocreate);
 if(!writefile)
 {  
cerr<<"cannot open the file for output"<<endl;  
exit(0);   } 
while(!readfile.eof()) 
{     
ch=readfile.get();      
x=static_cast<int>(ch);   
x=(x+3)%128;
strch=static_cast<char>(x);  
 writefile.put(strch);        
}
}

 

本文地址:http://com.8s8s.com/it/it29284.htm