Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- char information(char k) { //A function that receives as a character input, the function must calculate and return the encrypted //character to the resulting character
- int x = 0;
- if (k == 32) //space
- k = 32;
- if (k >= 48 && k <= 57) { //0-9
- x = k - 48;
- k = 57 - x;
- }
- else if (k >= 65 && k <= 90) { //A-Z
- x = k - 65;
- k = 90 - x;
- }
- else if (k >= 97 && k <= 122) { //a-z
- x = k - 97;
- k = 122 - x;
- }
- return k;
- }
- int main() {
- char k ;
- ifstream data("data.txt"); //open file
- ofstream encoding("encoding.txt"); //open the file
- if (!data||!encoding) { //checking the file
- cout << "can not open the file" << endl;
- return -1;
- }
- k = data.get();
- while (!data.eof()) { //do it until finish reading data text
- encoding << information(k);;
- k=data.get();
- }
- data.close();
- encoding.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement